@@ -250,17 +250,18 @@ def get_names(orcid):
250
250
return family_name , given_name
251
251
252
252
253
- def write_s3cmd_config (access_key , secret_key ):
253
+ def write_s3cmd_config (access_key , secret_key , endpoint ):
254
254
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]
258
259
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 }
261
262
secret_key = { secret_key }
262
263
"""
263
- )
264
+ )
264
265
265
266
266
267
def upload_supporting_file (record_id = None ):
@@ -272,12 +273,15 @@ def upload_supporting_file(record_id=None):
272
273
"Do you want to upload or link data files? (upload/link/n): "
273
274
).lower ()
274
275
if choice == "link" :
276
+ endpoint = "sdsc.osn.xsede.org"
277
+ path = "ini230004-bucket01/"
275
278
if not record_id :
276
279
access_key = get_user_input ("Enter the access key: " )
277
280
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 )
279
282
print ("""S3 connection configured.""" )
280
283
break
284
+ endpoint = f"https://{ endpoint } /"
281
285
s3 = s3fs .S3FileSystem (anon = True , client_kwargs = {"endpoint_url" : endpoint })
282
286
# Find the files
283
287
files = s3 .glob (path + record_id + "/*" )
@@ -414,7 +418,7 @@ def create_record():
414
418
print (
415
419
f"""You can view and publish this record at https://data.caltechlibrary.dev/uploads/{ rec_id }
416
420
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 } / """
418
422
)
419
423
break
420
424
else :
@@ -479,7 +483,7 @@ def create_record():
479
483
print (
480
484
f"""You can view and publish this record at https://data.caltechlibrary.dev/uploads/{ rec_id }
481
485
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 } / """
483
487
)
484
488
with open (response + ".json" , "w" ) as file :
485
489
json .dump (metadata , file , indent = 2 )
0 commit comments