diff --git a/a3m/client/clientScripts/a3m_store_aip.py b/a3m/client/clientScripts/a3m_store_aip.py index beb00591..bd0886f8 100644 --- a/a3m/client/clientScripts/a3m_store_aip.py +++ b/a3m/client/clientScripts/a3m_store_aip.py @@ -8,6 +8,7 @@ from a3m.client import metrics +from pathlib import Path logger = logging.getLogger(__name__) @@ -36,7 +37,15 @@ def _upload_file(path, bucket, key): boto_args.update(config=config) s3 = boto3.resource(**boto_args) - s3.meta.client.upload_file(path, bucket, key) + + # TODO: The S3 path should include a pre-defined directory path for the AIP + # We could use a predefined variable in the configuration file for a global A3M Storage such as predefined/global/path// + # Alternatively, we could use a predefined variable specifically for the AIP location such as predefined/aip/location/ + # In any case, the S3 path must be structured in a way that makes it easy to locate and manage the AIP. + s3_path = key + path.suffix + + logger.info(s3_path) + s3.meta.client.upload_file(str(path), bucket, s3_path) def _store_aip(job, sip_id, aip_path): @@ -51,7 +60,7 @@ def _store_aip(job, sip_id, aip_path): raise Exception("AIP is a directory") logger.info("Uploading AIP...") - _upload_file(str(aip_path), settings.S3_BUCKET, sip_id) + _upload_file(aip_path, settings.S3_BUCKET, sip_id) def call(jobs): @@ -59,5 +68,5 @@ def call(jobs): with transaction.atomic(): with job.JobContext(): sip_id = job.args[1] - aip_path = job.args[2] + aip_path = Path(job.args[2]) job.set_status(_store_aip(job, sip_id, aip_path))