You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However, it's not true that file must simply be type IO. Because .name is called on that object:
filename=path.basename(file.name)
it seems that the method actually expects the object to be of type FileIO, a subtype of IO and the type that you get when you use the builtin open function.
This is unwieldy when dealing with a file that is not stored on disk. In that case, I have access to the file's bytes and I have its filename. But I can't create a FileIO object to pass to upload_file without writing disk (creating a FileIO automatically writes to disk). In the meantime I am creating a subclass of BytesIO that has a name property. So, the duck type satisfies the requirements of upload_file. But I think it should be straightforward to upload a file that is not on disk.
The text was updated successfully, but these errors were encountered:
The Sandbox.upload_file method has the following signature:
However, it's not true that
file
must simply be typeIO
. Because.name
is called on that object:it seems that the method actually expects the object to be of type
FileIO
, a subtype ofIO
and the type that you get when you use the builtinopen
function.This is unwieldy when dealing with a file that is not stored on disk. In that case, I have access to the file's bytes and I have its filename. But I can't create a FileIO object to pass to
upload_file
without writing disk (creating a FileIO automatically writes to disk). In the meantime I am creating a subclass of BytesIO that has a name property. So, the duck type satisfies the requirements ofupload_file
. But I think it should be straightforward to upload a file that is not on disk.The text was updated successfully, but these errors were encountered: