Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError in DropboxFile #620

Closed
MichaelPak opened this issue Oct 24, 2018 · 3 comments
Closed

AttributeError in DropboxFile #620

MichaelPak opened this issue Oct 24, 2018 · 3 comments

Comments

@MichaelPak
Copy link

MichaelPak commented Oct 24, 2018

Version 1.7.1

Trying to get bytes from DropboxFile. It has property file:

@property
def file(self):
    if not hasattr(self, '_file'):
        response = self._storage.client.files_download(self.name)
        self._file = SpooledTemporaryFile()
        copyfileobj(response, self._file)
        self._file.seek(0)
    return self._file

But response is a tuple of objects Response and FileMetadata, so I'm getting next error:

  File "/.../myapp/mailing.py", line 50, in distribute
    part.set_payload(offer_file.file.read())
  File "/.../python3.6/site-packages/django/core/files/utils.py", line 16, in <lambda>
    read = property(lambda self: self.file.read)
  File "/.../python3.6/site-packages/django/core/files/utils.py", line 16, in <lambda>
    read = property(lambda self: self.file.read)
  File "/.../python3.6/site-packages/storages/backends/dropbox.py", line 45, in file
    copyfileobj(response, self._file)
  File "/.../python3.6/shutil.py", line 79, in copyfileobj
    buf = fsrc.read(length)
AttributeError: 'tuple' object has no attribute 'read'
@sww314
Copy link
Contributor

sww314 commented Oct 24, 2018

This is fixed in #402. However, that pull request is not ready to merge. You can try the patch and see if it works for you.

@MichaelPak
Copy link
Author

I've installed django-storages from @danni's fork and it's work for me.

As far as I understand, the error appeared due to the update of dropbox package. Can you tell which version of dropbox I should use?

@jschneier
Copy link
Owner

Fixed by #724.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants