diff --git a/storages/backends/s3.py b/storages/backends/s3.py index 497b0e99..3edc3c9a 100644 --- a/storages/backends/s3.py +++ b/storages/backends/s3.py @@ -251,8 +251,9 @@ def _create_empty_on_close(self): def close(self): if self._is_dirty: - self._flush_write_buffer() - self._multipart.complete(MultipartUpload={"Parts": self._parts}) + if self._multipart is not None: + self._flush_write_buffer() + self._multipart.complete(MultipartUpload={"Parts": self._parts}) else: if self._multipart is not None: self._multipart.abort()