Skip to content

Commit f9e2561

Browse files
committed
Add back in endpoint
1 parent ae61797 commit f9e2561

File tree

2 files changed

+16
-12
lines changed

2 files changed

+16
-12
lines changed

caltechdata_api/cli.py

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -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

266267
def 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)

codemeta.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"codeRepository": "https://github.com/caltechlibrary/caltechdata_api",
77
"issueTracker": "https://github.com/caltechlibrary/caltechdata_api/issues",
88
"license": "https://data.caltech.edu/license",
9-
"version": "1.6.0",
9+
"version": "1.6.1",
1010
"author": [
1111
{
1212
"@type": "Person",
@@ -20,7 +20,7 @@
2020
"@id": "https://orcid.org/0000-0001-9266-5146"
2121
}],
2222
"developmentStatus": "active",
23-
"downloadUrl": "https://github.com/caltechlibrary/caltechdata_api/archive/1.5.1.zip",
23+
"downloadUrl": "https://github.com/caltechlibrary/caltechdata_api/archive/1.6.1.zip",
2424
"keywords": [
2525
"GitHub",
2626
"metadata",

0 commit comments

Comments
 (0)