MCPcopy Create free account
hub / github.com/adobe/Marinus / write_file

Method write_file

python3_cron_scripts/libs3/AWSStorageManager.py:91–109  ·  view source on GitHub ↗

Write a file to AWS

(self, folder: str, filename: str, data: bytes)

Source from the content-addressed store, hash-verified

89 self._auth_to_amazon(config)
90
91 def write_file(self, folder: str, filename: str, data: bytes) -> bool:
92 """
93 Write a file to AWS
94 """
95 try:
96 s3_object = self._s3_resource.Object(folder, filename)
97 result = s3_object.put(Body=data)
98 res = result.get("ResponseMetadata")
99 return_status = res.get("HTTPStatusCode")
100 if return_status != 200:
101 self._logger.error("Unsuccessful upload to S3")
102 self._logger.error("HTTP Status Code: " + str(return_status))
103 return False
104 except Exception as err:
105 self._logger.error("Unable to upload file: " + filename + " to S3")
106 self._logger.error(str(err))
107 return False
108
109 return True
110
111 def write_large_file(
112 self, folder: str, remote_file_name: str, local_file_path: str

Callers 3

mainFunction · 0.45
write_fileFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected