Skip to content

Commit

Permalink
[azure] Add method to set ContentDisposition
Browse files Browse the repository at this point in the history
  • Loading branch information
drnextgis committed Jun 14, 2020
1 parent 8321ff5 commit 7d537f6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions storages/backends/azure_storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,10 +239,17 @@ def size(self, name):
timeout=self.timeout).properties
return properties.content_length

def content_disposition(self, name):
"""
Override this method to adjust this on a per-object basis to set ContentDisposition.
"""
return None

def _save(self, name, content):
cleaned_name = clean_name(name)
name = self._get_valid_path(name)
guessed_type, content_encoding = mimetypes.guess_type(name)
content_disposition = self.content_disposition(name)
content_type = (
_content_type(content) or
guessed_type or
Expand All @@ -260,6 +267,7 @@ def _save(self, name, content):
content_settings=ContentSettings(
content_type=content_type,
content_encoding=content_encoding,
content_disposition=content_disposition,
cache_control=self.cache_control),
max_connections=self.upload_max_conn,
timeout=self.timeout)
Expand Down
1 change: 1 addition & 0 deletions tests/test_azure.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ def test_storage_save(self):
c_mocked.assert_called_once_with(
content_type='text/plain',
content_encoding=None,
content_disposition=None,
cache_control=None)

def test_storage_open_write(self):
Expand Down

0 comments on commit 7d537f6

Please sign in to comment.