Skip to content

How to get file path saved to MemoryFs? #541

@coolice2015

Description

@coolice2015

Hi,

May I ask your kind help on a dummie question, I am strugling with in related to MemoryFs ?

I need to pass a screenshot image to telegram chat, and its only accept file path or url for the image:

photo_file_fullpath = "" # variable to store the image full path
bot.sendPhoto (<id>, photo = open (photo_file_fullpath, 'rb')

Its working perfectly when i save the image file on local files system, but I would like to avoid that, so I though I use MemoryFS as "memory filesystem" and access the file form there. To keep it simple, I do the following:

    from fs.memoryfs import MemoryFS
    import pyautogui
    
    screenshot_image = pyautogui.screenshot ()
    
    mem_fs = MemoryFS()
    storage = mem_fs.open ("test_image.png", 'wb')
    screenshot_image.save (storage)
    storage.close ()
    
.... need to acccess the saved image with by memoryfs file path ....

    mem_fs.close()

Could you help me please how can I get the file path of the image file stored in memoryfs as string on windows to be able to pass it to photo_file_fullpath variable and tehrefore sendPhoto could acces it (so it'll behave as a normal file) ?

Many thanks for your time and help!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions