filestack/filestack-python

Why does the upload method discards all the data returned by the upload?

heprotecbuthealsoattac opened this issue · 4 comments

So the upload() method discards all the metadata which has to be re-queried later from an unreliable api that fails often. Could you add this metadata to eaither filelink object or keep it in memory somewhere so that it's easy to get?

bkwi commented

Hi @heprotecbuthealsoattac,

First of all, I'm sorry for such a late response.
Which metadata items do you need to re-query for most often? And how often would you say our api fails?
We are currently making some changes to our metadata API and I hope we'll be able to address reliability issues.

@bkwi I need things like: 'url', 'container', 'filename', 'key', 'size'. All this data is availble to the python module after just uploading the file but is discarded later on which is a problem because I need to re-query the metadata api to get it back, however it did fail on me rather often. I was setting up a monitoring system that was uploading the files via python to 'emulate' user's interaction with filestack and had to resort to this kind of 'hack':

from filestack.uploads.multipart import multipart_upload

CLIENT = Client(FS_API_KEY)
metadata = multipart_upload(
        CLIENT.apikey,
        FILE_PATH,
        None,
        CLIENT.storage,
        params={
            'filename': filename,
            'path': path,
            'location': 's3',
            'access': 'private'
        },
        security=CLIENT.security
    )

    r = do_stuff_with_the_metadata(metadata'])
bkwi commented

we could try and add an additional attribute to Filelink class that would be populated only when object was created as a result of a file upload:

flink = client.upload(...)
flink.upload_response  # would contain all the data that was returned
# but
flink = Filelink(<HANDLE>)
flink.upload_response # would be None
bkwi commented

hi @heprotecbuthealsoattac

filestack-python==3.4.0 has just been released. It contains changes described in my previous comment. Sorry it took so long.