12345678910111213141516171819202122 |
- def upload(self, file_dict):
- upload_response = {}
- for key in file_dict:
- print("File Dict Key: [{}] value is: {}".format(key, file_dict[key]))
- print("\nUploading to Azure Storage as blob:\n\t" + key)
- self.blob_client = self.blob_service_client.get_blob_client(container=self.get_config('container_name'), blob=key)
- with open(file_dict[key], "rb") as data:
- try:
- self.blob_client.upload_blob(data)
- print('File: Uploaded Successfully: {}'.format(key))
- upload_response[key] = 'Successfully Uploaded'
- except ResourceExistsError:
- print('File: NOT Uploaded Successfully: {}'.format(key))
- upload_response[key] = 'This Resource already exists'
- upload_response['Partial'] = True
- print('This Resource already exists')
- # return 'This Resource already exists'
- print("Before Returning Response:")
- print(jsonify(upload_response))
- print("---------------")
- return upload_response
|