algorithmia-python icon indicating copy to clipboard operation
algorithmia-python copied to clipboard

putFile should accept either a path or file object

Open pmcq opened this issue 9 years ago • 3 comments

Currently only accepts a path and errors on a file https://github.com/algorithmiaio/algorithmia-python/blob/master/Algorithmia/datafile.py#L95-L102

pmcq avatar Dec 28 '16 20:12 pmcq

Is putFile no longer supported? Readme still has putFile in the sample code for uploading files.

op = client.dir('s3+label://path') op.putFile('Jellyfish.jpg') Traceback (most recent call last): File "", line 1, in AttributeError: 'DataDirectory' object has no attribute 'putFile'

JanakiJoshi avatar Jun 25 '18 08:06 JanakiJoshi

putFile is supported but the documentation was not accurate. That has been corrected with https://github.com/algorithmiaio/algorithmia-python/commit/e2d4a585712f3415134b8e00b2f6b6495d920ff5. @JanakiJoshi, in your code you need to get a File object first to call the putFile method

jamesatha avatar Jun 25 '18 15:06 jamesatha

This bug was created because putFile can only take a file path instead of a file object. In my opinion, it's nice forcing a path since it ensures that the user cannot accidentally give us a handle that is in the middle or end of the file. The downside is that the user cannot use any 'file-like' objects

We are still considering whether its capabilities should be broadened.

jamesatha avatar Jun 25 '18 15:06 jamesatha