Wauplin HF Staff commited on
Commit
4d8dbe7
·
verified ·
1 Parent(s): 4bdf622

Upload folder using huggingface_hub

Browse files
Files changed (2) hide show
  1. app.js +15 -11
  2. index.html +4 -3
app.js CHANGED
@@ -261,8 +261,8 @@ async function connectS3() {
261
  const prefix = dom.s3Prefix.value.trim();
262
 
263
  // Validation
264
- if (!accessKey || !secretKey || !bucket) {
265
- dom.s3ConnectError.textContent = "Please fill in all required fields.";
266
  dom.s3ConnectError.style.color = "var(--error)";
267
  return;
268
  }
@@ -281,11 +281,16 @@ async function connectS3() {
281
  // Create S3 client
282
  const clientConfig = {
283
  region,
284
- credentials: {
 
 
285
  accessKeyId: accessKey,
286
  secretAccessKey: secretKey,
287
- },
288
- };
 
 
 
289
  if (endpoint) {
290
  clientConfig.endpoint = endpoint;
291
  clientConfig.forcePathStyle = true;
@@ -887,9 +892,12 @@ async function submitImportJob() {
887
  if (bufferSize) {
888
  script += ` --buffer-size ${shellEscape(bufferSize)}`;
889
  }
890
- script += ` --verbose`;
891
 
892
  // Step 3: Submit job
 
 
 
 
893
  const jobPayload = {
894
  dockerImage: "python:3.12",
895
  command: ["bash", "-c", script],
@@ -899,11 +907,7 @@ async function submitImportJob() {
899
  environment: {
900
  AWS_DEFAULT_REGION: state.s3Region || "us-east-1",
901
  },
902
- secrets: {
903
- AWS_ACCESS_KEY_ID: state.awsAccessKeyId,
904
- AWS_SECRET_ACCESS_KEY: state.awsSecretAccessKey,
905
- HF_TOKEN: token,
906
- },
907
  };
908
 
909
  if (state.s3Endpoint) {
 
261
  const prefix = dom.s3Prefix.value.trim();
262
 
263
  // Validation
264
+ if (!bucket) {
265
+ dom.s3ConnectError.textContent = "Please provide an S3 bucket name.";
266
  dom.s3ConnectError.style.color = "var(--error)";
267
  return;
268
  }
 
281
  // Create S3 client
282
  const clientConfig = {
283
  region,
284
+ };
285
+ if (accessKey && secretKey) {
286
+ clientConfig.credentials = {
287
  accessKeyId: accessKey,
288
  secretAccessKey: secretKey,
289
+ };
290
+ } else {
291
+ // Anonymous access for public buckets
292
+ clientConfig.signer = { sign: async (request) => request };
293
+ }
294
  if (endpoint) {
295
  clientConfig.endpoint = endpoint;
296
  clientConfig.forcePathStyle = true;
 
892
  if (bufferSize) {
893
  script += ` --buffer-size ${shellEscape(bufferSize)}`;
894
  }
 
895
 
896
  // Step 3: Submit job
897
+ const secrets = { HF_TOKEN: token };
898
+ if (state.awsAccessKeyId) secrets.AWS_ACCESS_KEY_ID = state.awsAccessKeyId;
899
+ if (state.awsSecretAccessKey) secrets.AWS_SECRET_ACCESS_KEY = state.awsSecretAccessKey;
900
+
901
  const jobPayload = {
902
  dockerImage: "python:3.12",
903
  command: ["bash", "-c", script],
 
907
  environment: {
908
  AWS_DEFAULT_REGION: state.s3Region || "us-east-1",
909
  },
910
+ secrets,
 
 
 
 
911
  };
912
 
913
  if (state.s3Endpoint) {
index.html CHANGED
@@ -71,25 +71,26 @@
71
  <div class="form-grid">
72
  <div class="form-group">
73
  <div class="label-row">
74
- <label>AWS Access Key ID <span class="required">*</span></label>
75
  <button type="button" class="help-toggle" data-help="help-access-key">?</button>
76
  </div>
77
  <input type="text" id="aws-access-key" placeholder="AKIA..." autocomplete="off" spellcheck="false">
78
  <div id="help-access-key" class="field-help">
79
  Your IAM access key ID, starting with <code>AKIA</code>. You can create one in the
80
  <a href="https://console.aws.amazon.com/iam/home#/security_credentials" target="_blank" rel="noopener">AWS IAM Console</a>
81
- under "Access keys". We recommend using a key with read-only S3 permissions.
82
  </div>
83
  </div>
84
  <div class="form-group">
85
  <div class="label-row">
86
- <label>AWS Secret Access Key <span class="required">*</span></label>
87
  <button type="button" class="help-toggle" data-help="help-secret-key">?</button>
88
  </div>
89
  <input type="password" id="aws-secret-key" placeholder="Your secret key" autocomplete="off">
90
  <div id="help-secret-key" class="field-help">
91
  The secret key paired with your Access Key ID. It was shown only once when you created the access key.
92
  This value is sent to the HF Job as an encrypted secret and is not persisted beyond the Job's lifetime.
 
93
  </div>
94
  </div>
95
  <div class="form-group">
 
71
  <div class="form-grid">
72
  <div class="form-group">
73
  <div class="label-row">
74
+ <label>AWS Access Key ID <span class="text-muted">(optional for public buckets)</span></label>
75
  <button type="button" class="help-toggle" data-help="help-access-key">?</button>
76
  </div>
77
  <input type="text" id="aws-access-key" placeholder="AKIA..." autocomplete="off" spellcheck="false">
78
  <div id="help-access-key" class="field-help">
79
  Your IAM access key ID, starting with <code>AKIA</code>. You can create one in the
80
  <a href="https://console.aws.amazon.com/iam/home#/security_credentials" target="_blank" rel="noopener">AWS IAM Console</a>
81
+ under "Access keys". Leave empty for public S3 buckets that allow anonymous read access.
82
  </div>
83
  </div>
84
  <div class="form-group">
85
  <div class="label-row">
86
+ <label>AWS Secret Access Key <span class="text-muted">(optional for public buckets)</span></label>
87
  <button type="button" class="help-toggle" data-help="help-secret-key">?</button>
88
  </div>
89
  <input type="password" id="aws-secret-key" placeholder="Your secret key" autocomplete="off">
90
  <div id="help-secret-key" class="field-help">
91
  The secret key paired with your Access Key ID. It was shown only once when you created the access key.
92
  This value is sent to the HF Job as an encrypted secret and is not persisted beyond the Job's lifetime.
93
+ Leave empty for public S3 buckets.
94
  </div>
95
  </div>
96
  <div class="form-group">