def _save(self, name, content): """ :param name: :param File content: :return: """ original_name = name.get("original_name") blob_file_name = datetime.now().strftime("%Y%m%d-%H:%M:%S.%f_") + original_name # blob_name = "{}.{}".format(name.get("uuid"), original_name.partition(".")[-1]) if hasattr(content.file, 'content_type'): content_type = content.file.content_type else: content_type = mimetypes.guess_type(original_name) if hasattr(content, 'chunks'): content_data = b''.join(chunk for chunk in content.chunks()) else: content_data = content.read() print(f'Saving blob: container={self.azure_container}, blob={blob_file_name}') blob_client = self.connection.get_blob_client(container=self.azure_container, blob=blob_file_name) obj = blob_client.upload_blob(content_data) # create_blob_from_bytes(self.azure_container, name, content_data, # # content_settings=ContentSettings(content_type=content_type)) af = AttachedFile(original_name, self.azure_container, blob_file_name) return af