@@ -254,6 +254,18 @@ def get_names(orcid):
254254 return family_name , given_name
255255
256256
257+ def write_s3cmd_config (access_key , secret_key ):
258+ with open ("~/.s3cfg" , "w" ) as file :
259+ file .write (
260+ f"""[default]
261+ access_key = { access_key }
262+ host_base = sdsc.osn.xsede.org
263+ host_bucket = %(bucket).sdsc.osn.xsede.org
264+ secret_key = { secret_key }
265+ """
266+ )
267+
268+
257269def upload_supporting_file (record_id = None ):
258270 filepath = ""
259271 filepaths = []
@@ -263,14 +275,11 @@ def upload_supporting_file(record_id=None):
263275 "Do you want to upload or link data files? (upload/link/n): "
264276 ).lower ()
265277 if choice == "link" :
266- endpoint = "https://sdsc.osn.xsede.org/"
267- path = "ini230004-bucket01/"
268-
269278 if not record_id :
270- print (
271- """Please upload the metadata to CaltechDATA, and you'll be provided
272- instructions to upload the files to S3 directly."""
273- )
279+ access_key = get_user_input ( "Enter the access key: " )
280+ secret_key = get_user_input ( "Enter the secret key: " )
281+ write_s3cmd_config ( access_key , secret_key )
282+ print ( """S3 connection configured.""" )
274283 break
275284 s3 = s3fs .S3FileSystem (anon = True , client_kwargs = {"endpoint_url" : endpoint })
276285 # Find the files
@@ -407,9 +416,8 @@ def create_record():
407416 rec_id = response
408417 print (
409418 f"""You can view and publish this record at https://data.caltechlibrary.dev/uploads/{ rec_id }
410- If you need to upload large files to S3, you can type `s3cmd
411- --endpoint-url https://renc.osn.xsede.org:443 cp DATA_FILE
412- s3://ini210004tommorrell/{ rec_id } """
419+ If you need to upload large files to S3, you can type
420+ `s3cmd put DATA_FILE s3://ini230004-bucket01/{ rec_id } """
413421 )
414422 break
415423 else :
@@ -473,9 +481,8 @@ def create_record():
473481 rec_id = response
474482 print (
475483 f"""You can view and publish this record at https://data.caltechlibrary.dev/uploads/{ rec_id }
476- If you need to upload large files to S3, you can type `s3cmd
477- --endpoint-url https://renc.osn.xsede.org:443 cp DATA_FILE
478- s3://ini210004tommorrell/{ rec_id } """
484+ If you need to upload large files to S3, you can type
485+ `s3cmd put DATA_FILE s3://ini230004-bucket01/{ rec_id } """
479486 )
480487 with open (response + ".json" , "w" ) as file :
481488 json .dump (metadata , file , indent = 2 )
0 commit comments