@sparkstudio/storage-ui 1.0.8 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -240,17 +240,18 @@ var UploadContainer = ({
240
240
  throw new Error("getPresignedUrl is not provided.");
241
241
  }
242
242
  const presignedUrl = await getPresignedUrl(upload.file);
243
- await uploadFileToS3(upload.file, presignedUrl, (progress) => {
243
+ const url = presignedUrl?.PresignedUrl ?? "";
244
+ await uploadFileToS3(upload.file, url, (progress) => {
244
245
  setUploads(
245
246
  (prev) => prev.map(
246
247
  (u) => u.id === upload.id ? { ...u, progress } : u
247
248
  )
248
249
  );
249
250
  });
250
- const fileUrl = presignedUrl.split("?")[0];
251
+ const fileUrl = url.split("?")[0];
251
252
  setUploads(
252
253
  (prev) => prev.map(
253
- (u) => u.id === upload.id ? { ...u, status: "success", progress: 100, s3Url: fileUrl } : u
254
+ (u) => u.id === upload.id ? { ...u, status: "success", progress: 100, s3Url: fileUrl, publicUrl: presignedUrl.PublicUrl } : u
254
255
  )
255
256
  );
256
257
  onUploadComplete?.(upload.file, fileUrl);
@@ -331,7 +332,11 @@ var UploadContainer = ({
331
332
  ] }),
332
333
  uploads.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "mt-3", children: uploads.map((u) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "mb-2", children: [
333
334
  /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "d-flex justify-content-between small mb-1", children: [
334
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: u.file.name }),
335
+ /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", { children: [
336
+ u.file.name,
337
+ " - ",
338
+ u?.publicUrl ?? ""
339
+ ] }),
335
340
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: u.status === "success" ? "Completed" : u.status === "error" ? "Error" : `${u.progress}%` })
336
341
  ] }),
337
342
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "progress", style: { height: "6px" }, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
@@ -387,9 +392,9 @@ function HomeView() {
387
392
  alert(user?.Id);
388
393
  }
389
394
  const getPresignedUrl = async (file) => {
390
- const sdk = new SparkStudioStorageSDK("https://localhost:5001");
395
+ const sdk = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
391
396
  const result = await sdk.container.GetPreSignedUrl(file.name, file.size, encodeURIComponent(file.type));
392
- return result?.PresignedUrl ?? "";
397
+ return result;
393
398
  };
394
399
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
395
400
  import_authentication_ui.AuthenticatorProvider,
package/dist/index.d.cts CHANGED
@@ -96,7 +96,7 @@ interface UploadContainerProps {
96
96
  * Your function that returns a pre-signed URL for a given file.
97
97
  * Typically calls your backend: /api/uploads/presign
98
98
  */
99
- getPresignedUrl?: (file: File) => Promise<string>;
99
+ getPresignedUrl?: (file: File) => Promise<AWSPresignedUrlDTO>;
100
100
  /**
101
101
  * Called when a file has successfully finished uploading.
102
102
  * s3Url is usually the final S3 object URL or key (depends on your backend).
package/dist/index.d.ts CHANGED
@@ -96,7 +96,7 @@ interface UploadContainerProps {
96
96
  * Your function that returns a pre-signed URL for a given file.
97
97
  * Typically calls your backend: /api/uploads/presign
98
98
  */
99
- getPresignedUrl?: (file: File) => Promise<string>;
99
+ getPresignedUrl?: (file: File) => Promise<AWSPresignedUrlDTO>;
100
100
  /**
101
101
  * Called when a file has successfully finished uploading.
102
102
  * s3Url is usually the final S3 object URL or key (depends on your backend).
package/dist/index.js CHANGED
@@ -207,17 +207,18 @@ var UploadContainer = ({
207
207
  throw new Error("getPresignedUrl is not provided.");
208
208
  }
209
209
  const presignedUrl = await getPresignedUrl(upload.file);
210
- await uploadFileToS3(upload.file, presignedUrl, (progress) => {
210
+ const url = presignedUrl?.PresignedUrl ?? "";
211
+ await uploadFileToS3(upload.file, url, (progress) => {
211
212
  setUploads(
212
213
  (prev) => prev.map(
213
214
  (u) => u.id === upload.id ? { ...u, progress } : u
214
215
  )
215
216
  );
216
217
  });
217
- const fileUrl = presignedUrl.split("?")[0];
218
+ const fileUrl = url.split("?")[0];
218
219
  setUploads(
219
220
  (prev) => prev.map(
220
- (u) => u.id === upload.id ? { ...u, status: "success", progress: 100, s3Url: fileUrl } : u
221
+ (u) => u.id === upload.id ? { ...u, status: "success", progress: 100, s3Url: fileUrl, publicUrl: presignedUrl.PublicUrl } : u
221
222
  )
222
223
  );
223
224
  onUploadComplete?.(upload.file, fileUrl);
@@ -298,7 +299,11 @@ var UploadContainer = ({
298
299
  ] }),
299
300
  uploads.length > 0 && /* @__PURE__ */ jsx("div", { className: "mt-3", children: uploads.map((u) => /* @__PURE__ */ jsxs("div", { className: "mb-2", children: [
300
301
  /* @__PURE__ */ jsxs("div", { className: "d-flex justify-content-between small mb-1", children: [
301
- /* @__PURE__ */ jsx("span", { children: u.file.name }),
302
+ /* @__PURE__ */ jsxs("span", { children: [
303
+ u.file.name,
304
+ " - ",
305
+ u?.publicUrl ?? ""
306
+ ] }),
302
307
  /* @__PURE__ */ jsx("span", { children: u.status === "success" ? "Completed" : u.status === "error" ? "Error" : `${u.progress}%` })
303
308
  ] }),
304
309
  /* @__PURE__ */ jsx("div", { className: "progress", style: { height: "6px" }, children: /* @__PURE__ */ jsx(
@@ -354,9 +359,9 @@ function HomeView() {
354
359
  alert(user?.Id);
355
360
  }
356
361
  const getPresignedUrl = async (file) => {
357
- const sdk = new SparkStudioStorageSDK("https://localhost:5001");
362
+ const sdk = new SparkStudioStorageSDK("https://lf9zyufpuk.execute-api.us-east-2.amazonaws.com/Prod");
358
363
  const result = await sdk.container.GetPreSignedUrl(file.name, file.size, encodeURIComponent(file.type));
359
- return result?.PresignedUrl ?? "";
364
+ return result;
360
365
  };
361
366
  return /* @__PURE__ */ jsxs2(
362
367
  AuthenticatorProvider,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkstudio/storage-ui",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",