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

dropbox api v1 is deprecated #227

Closed
patroqueeet opened this issue Nov 17, 2016 · 13 comments
Closed

dropbox api v1 is deprecated #227

patroqueeet opened this issue Nov 17, 2016 · 13 comments
Labels

Comments

@patroqueeet
Copy link

https://github.com/dropbox/dropbox-sdk-python/blob/master/dropbox/client.py#L48

so we should move to using dropbox.Dropbox instead?

@maxmalysh
Copy link
Contributor

maxmalysh commented May 3, 2017

Dropbox storage will stop working in two months:

June 28, 2017: API v1 endpoints are turned off.

https://blogs.dropbox.com/developers/2016/06/api-v1-deprecated/

@django-dbbackup, @ZuluPro, just want to mention that this issue will affect django-dbbackup.

@jschneier
Copy link
Owner

Can you test #273?

@patroqueeet
Copy link
Author

It started failing a few days ago. investigation under way

@patroqueeet
Copy link
Author

patroqueeet commented May 3, 2017

tests done. as of now neither 1.5.0 nor my ancient fork are working... fails with

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
    utility.execute()
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute
    output = self.handle(*args, **options)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dbbackup/utils.py", line 111, in wrapper
    func(*args, **kwargs)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dbbackup/management/commands/mediabackup.py", line 52, in handle
    self.backup_mediafiles()
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dbbackup/management/commands/mediabackup.py", line 103, in backup_mediafiles
    self.write_to_storage(tarball, filename)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dbbackup/management/commands/_base.py", line 88, in write_to_storage
    self.storage.write_file(file, path)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dbbackup/storage.py", line 82, in write_file
    self.storage.save(name=filename, content=filehandle)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/django/core/files/storage.py", line 63, in save
    name = self._save(name, content)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/storages/backends/dropbox.py", line 112, in _save
    self.client.files_upload(content, self._full_path(name))
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dropbox/base.py", line 1225, in files_upload
    f,
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dropbox/dropbox.py", line 249, in request
    timeout=timeout)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dropbox/dropbox.py", line 341, in request_json_string_with_retry
    timeout=timeout)
  File "/home/darg/darg/.ve/local/lib/python2.7/site-packages/dropbox/dropbox.py", line 461, in request_json_string
    raise HttpError(request_id, r.status_code, r.text)
dropbox.exceptions.HttpError: HttpError('0df0fe9d19d5f9030babe2d648bd8249', 413, u'<!DOCTYPE html>...

the same error is also happening on this repos dropbox-api-upgrade branch

@jschneier
Copy link
Owner

Are you hitting the large files upload issue? My branch proceeds that issue by several months. If not do you have the full traceback? An html page is admittedly not the best thing to return...

@patroqueeet
Copy link
Author

patroqueeet commented May 3, 2017

large file upload issue??? have about 600MB...

#301? sounds like that...

@jschneier
Copy link
Owner

1 file? #301 was opened 2 hours ago.

@patroqueeet
Copy link
Author

sounds very reasonable... is a fix expected soon? or will it take some time?

@jschneier
Copy link
Owner

Happy to accept a PR. There is a link to follow in the issue that has a stack overflow link to some possible code as a starter. If no one else gets to it I hope to be able to look into it this weekend, I don't think the fix is difficult in this case since Dropbox does provide some sort of api but time is always the key part.

@patroqueeet
Copy link
Author

patroqueeet commented May 3, 2017

I'm in a rush here... I can venture a PR based on the SO issue, but would appreciate a fast pypi update then (I hate keeping local forks :))

If my code will be of insufficient quality, just reject .... but I like giving it a try...

@patroqueeet
Copy link
Author

patroqueeet commented May 3, 2017

may I ask you for a quick feedback:

   67     def _chunked_upload(self, content, dest_path):
   68         """use chunked upload session for large files. stolen from
   69         https://goo.gl/4XV0yT"""
   70
   71         file_size = len(content)
   72         f = StringIO.STringIO(content)
   73
   74         upload_session_start_result = (
   75             self.client.files_upload_session_start(f.read(self.CHUNK_SIZE)))
   76         cursor = UploadSessionCursor(
   77             session_id=upload_session_start_result.session_id,
   78             offset=f.tell())
   79         commit = CommitInfo(path=dest_path)
   80
   81         while f.tell() < file_size:
   82             if ((file_size - f.tell()) <= self.fCHUNK_SIZE):
   83                 self.client.files_upload_session_finish(
   84                     f.read(self.CHUNK_SIZE), cursor, commit)
   85             else:
   86                 self.client.files_upload_session_append(
   87                     f.read(self.CHUNK_SIZE), cursor.session_id,
   88                     cursor.offset)
   89                 cursor.offset = f.tell()
   90
   91         del f

and

  142     def _save(self, name, content):
  143         file_size = len(content)
  144         if file_size <= self.CHUNK_SIZE:
  145             self.client.files_upload(content, self._full_path(name))
  146         else:
  147             self._chunked_upload(content, self._full_path(name))
  148         return name

and

131     @mock.patch('dropbox.Dropbox.files_upload_session_append',
132                 return_value='foo')
133     def test_save_large_files(self, *args):
134         s = u''
135         for i in xrange(self.storage.CHUNK_SIZE + 1):
136             s += random.choice(string.letters)
137         self.storage._save('foo', b'{}'.format(s))

@patroqueeet
Copy link
Author

also quick help needed:

tox -e py27

gives me

____________________________________________________ ERROR collecting tests/test_utils.py _____________________________________________________
ImportError while importing test module '/home/jirsch/libs/django-storages/tests/test_utils.py'.
Hint: make sure your test modules/packages have valid Python names.
Traceback:
tests/test_utils.py:1: in <module>
    from django.test import TestCase
E   ImportError: No module named django.test

@jschneier
Copy link
Owner

Closed via #273 large file still in progress

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

No branches or pull requests

4 participants