@@ -250,17 +250,18 @@ def get_names(orcid):
250250 return family_name , given_name
251251
252252
253- def write_s3cmd_config (access_key , secret_key ):
253+ def write_s3cmd_config (access_key , secret_key , endpoint ):
254254 configf = os .path .join (home_directory , ".s3cfg" )
255- with open (configf , "w" ) as file :
256- file .write (
257- f"""[default]
255+ if not os .path .exists (key_file ):
256+ with open (configf , "w" ) as file :
257+ file .write (
258+ f"""[default]
258259 access_key = { access_key }
259- host_base = sdsc.osn.xsede.org
260- host_bucket = %(bucket).sdsc.osn.xsede.org
260+ host_base = { endpoint }
261+ host_bucket = %(bucket).{ endpoint }
261262 secret_key = { secret_key }
262263 """
263- )
264+ )
264265
265266
266267def upload_supporting_file (record_id = None ):
@@ -272,12 +273,15 @@ def upload_supporting_file(record_id=None):
272273 "Do you want to upload or link data files? (upload/link/n): "
273274 ).lower ()
274275 if choice == "link" :
276+ endpoint = "sdsc.osn.xsede.org"
277+ path = "ini230004-bucket01/"
275278 if not record_id :
276279 access_key = get_user_input ("Enter the access key: " )
277280 secret_key = get_user_input ("Enter the secret key: " )
278- write_s3cmd_config (access_key , secret_key )
281+ write_s3cmd_config (access_key , secret_key , endpoint )
279282 print ("""S3 connection configured.""" )
280283 break
284+ endpoint = f"https://{ endpoint } /"
281285 s3 = s3fs .S3FileSystem (anon = True , client_kwargs = {"endpoint_url" : endpoint })
282286 # Find the files
283287 files = s3 .glob (path + record_id + "/*" )
@@ -414,7 +418,7 @@ def create_record():
414418 print (
415419 f"""You can view and publish this record at https://data.caltechlibrary.dev/uploads/{ rec_id }
416420 If you need to upload large files to S3, you can type
417- `s3cmd put DATA_FILE s3://ini230004-bucket01/{ rec_id } """
421+ `s3cmd put DATA_FILE s3://ini230004-bucket01/{ rec_id } / """
418422 )
419423 break
420424 else :
@@ -479,7 +483,7 @@ def create_record():
479483 print (
480484 f"""You can view and publish this record at https://data.caltechlibrary.dev/uploads/{ rec_id }
481485 If you need to upload large files to S3, you can type
482- `s3cmd put DATA_FILE s3://ini230004-bucket01/{ rec_id } """
486+ `s3cmd put DATA_FILE s3://ini230004-bucket01/{ rec_id } / """
483487 )
484488 with open (response + ".json" , "w" ) as file :
485489 json .dump (metadata , file , indent = 2 )
0 commit comments