Uploaded image for project: 'Libcloud'
  1. Libcloud
  2. LIBCLOUD-1043

Azure Storage driver crashes when passed a non file-like iterator

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.4.0
    • latest
    • None
    • None

    Description

      The azure_blobs implementation of upload_object_via_stream(iterator, ...) currently assumes that the passed-in iterator always is a file-like object that implements seek(...) (source).

      This means that function crashes when used with arbitrary iterators as returned by iter(...).

      Notably, the libcloud integration for django-storages exercises this functionality (source) which makes django-storages + libcloud + Azure Blobs currently unusable. See detailed stacktrace below:

      Traceback (most recent call last):
        File ".../app/manage.py", line 15, in <module>
          execute_from_command_line(sys.argv)
        File "...\lib\site-packages\django\core\management\__init__.py", line 381, in execute_from_command_line
          utility.execute()
        File "...\lib\site-packages\django\core\management\__init__.py", line 375, in execute
          self.fetch_command(subcommand).run_from_argv(self.argv)
        File "...\lib\site-packages\django\core\management\base.py", line 316, in run_from_argv
          self.execute(*args, **cmd_options)
        File "...\lib\site-packages\django\core\management\base.py", line 353, in execute
          output = self.handle(*args, **options)
        File "...\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 188, in handle
          collected = self.collect()
        File "...\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 114, in collect
          handler(path, prefixed_path, storage)
        File "...\lib\site-packages\django\contrib\staticfiles\management\commands\collectstatic.py", line 353, in copy_file
          self.storage.save(prefixed_path, source_file)
        File "...\lib\site-packages\django\core\files\storage.py", line 49, in save
          return self._save(name, content)
        File "...\lib\site-packages\storages\backends\apache_libcloud.py", line 157, in _save
          self.driver.upload_object_via_stream(iter(file), self._get_bucket(), name)
        File "...\lib\site-packages\libcloud\storage\drivers\azure_blobs.py", line 828, in upload_object_via_stream
          iterator.seek(0, os.SEEK_END)
      AttributeError: 'generator' object has no attribute 'seek'
      

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              c-w Clemens Wolff
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 50m
                  1h 50m