@applica-software-guru/didonato-storage-client 1.0.39 → 1.0.41

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.d.mts CHANGED
@@ -104,6 +104,7 @@ interface UploadFileResponse {
104
104
  }
105
105
  interface IDidonatoStorageClient {
106
106
  createUploadSignature(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
107
+ createSignedUploadUrl(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
107
108
  finalizeUpload(req: FinalizeUploadRequest): Promise<FinalizeUploadResponse>;
108
109
  getFiles(req?: GetFilesRequest): Promise<GetFilesResponse>;
109
110
  getDownloadUrl(req: GetDownloadUrlRequest): Promise<GetDownloadUrlResponse>;
@@ -126,6 +127,7 @@ declare class DidonatoStorageClient implements IDidonatoStorageClient {
126
127
  private headers;
127
128
  private _fetch;
128
129
  createUploadSignature(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
130
+ createSignedUploadUrl(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
129
131
  finalizeUpload(req: FinalizeUploadRequest): Promise<FinalizeUploadResponse>;
130
132
  getFiles(req?: GetFilesRequest): Promise<GetFilesResponse>;
131
133
  getDownloadUrl(req: GetDownloadUrlRequest): Promise<GetDownloadUrlResponse>;
package/dist/index.d.ts CHANGED
@@ -104,6 +104,7 @@ interface UploadFileResponse {
104
104
  }
105
105
  interface IDidonatoStorageClient {
106
106
  createUploadSignature(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
107
+ createSignedUploadUrl(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
107
108
  finalizeUpload(req: FinalizeUploadRequest): Promise<FinalizeUploadResponse>;
108
109
  getFiles(req?: GetFilesRequest): Promise<GetFilesResponse>;
109
110
  getDownloadUrl(req: GetDownloadUrlRequest): Promise<GetDownloadUrlResponse>;
@@ -126,6 +127,7 @@ declare class DidonatoStorageClient implements IDidonatoStorageClient {
126
127
  private headers;
127
128
  private _fetch;
128
129
  createUploadSignature(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
130
+ createSignedUploadUrl(req: CreateUploadSignatureRequest): Promise<CreateUploadSignatureResponse>;
129
131
  finalizeUpload(req: FinalizeUploadRequest): Promise<FinalizeUploadResponse>;
130
132
  getFiles(req?: GetFilesRequest): Promise<GetFilesResponse>;
131
133
  getDownloadUrl(req: GetDownloadUrlRequest): Promise<GetDownloadUrlResponse>;
package/dist/index.js CHANGED
@@ -92,6 +92,17 @@ var DidonatoStorageClient = class {
92
92
  })
93
93
  });
94
94
  }
95
+ async createSignedUploadUrl(req) {
96
+ return this._fetch("/api/sign-upload", {
97
+ method: "POST",
98
+ headers: { "Content-Type": "application/json" },
99
+ body: JSON.stringify({
100
+ filename: req.filename,
101
+ contentType: req.contentType,
102
+ size: req.maxSize
103
+ })
104
+ });
105
+ }
95
106
  async finalizeUpload(req) {
96
107
  return this._fetch("/api/complete-upload", {
97
108
  method: "POST",
@@ -186,11 +197,12 @@ var DidonatoStorageClient = class {
186
197
  const filename = opts.filename ?? (file instanceof File ? file.name : "file.bin");
187
198
  const contentType = opts.contentType ?? (file instanceof File ? file.type || "application/octet-stream" : "application/octet-stream");
188
199
  const size = typeof opts.size === "number" ? opts.size : file instanceof File ? file.size : 0;
189
- const sig = await this.createUploadSignature({ filename, contentType, maxSize: size });
200
+ const sig = await this.createSignedUploadUrl({ filename, contentType, maxSize: size });
190
201
  if (!sig) throw new Error("No signature from server");
191
- if (sig.url || sig.uploadUrl) {
192
- const postUrl = sig.url || sig.uploadUrl;
193
- await this._uploadToSignedForm({ uploadUrl: postUrl, fields: sig.fields || {}, file, onProgress });
202
+ if (sig.uploadUrl) {
203
+ await this._uploadToSignedUrl({ uploadUrl: sig.uploadUrl, requiredHeaders: sig.requiredHeaders || {}, file, onProgress });
204
+ } else if (sig.url) {
205
+ await this._uploadToSignedForm({ uploadUrl: sig.url, fields: sig.fields || {}, file, onProgress });
194
206
  } else {
195
207
  throw new Error("No usable upload info from server");
196
208
  }
package/dist/index.mjs CHANGED
@@ -65,6 +65,17 @@ var DidonatoStorageClient = class {
65
65
  })
66
66
  });
67
67
  }
68
+ async createSignedUploadUrl(req) {
69
+ return this._fetch("/api/sign-upload", {
70
+ method: "POST",
71
+ headers: { "Content-Type": "application/json" },
72
+ body: JSON.stringify({
73
+ filename: req.filename,
74
+ contentType: req.contentType,
75
+ size: req.maxSize
76
+ })
77
+ });
78
+ }
68
79
  async finalizeUpload(req) {
69
80
  return this._fetch("/api/complete-upload", {
70
81
  method: "POST",
@@ -159,11 +170,12 @@ var DidonatoStorageClient = class {
159
170
  const filename = opts.filename ?? (file instanceof File ? file.name : "file.bin");
160
171
  const contentType = opts.contentType ?? (file instanceof File ? file.type || "application/octet-stream" : "application/octet-stream");
161
172
  const size = typeof opts.size === "number" ? opts.size : file instanceof File ? file.size : 0;
162
- const sig = await this.createUploadSignature({ filename, contentType, maxSize: size });
173
+ const sig = await this.createSignedUploadUrl({ filename, contentType, maxSize: size });
163
174
  if (!sig) throw new Error("No signature from server");
164
- if (sig.url || sig.uploadUrl) {
165
- const postUrl = sig.url || sig.uploadUrl;
166
- await this._uploadToSignedForm({ uploadUrl: postUrl, fields: sig.fields || {}, file, onProgress });
175
+ if (sig.uploadUrl) {
176
+ await this._uploadToSignedUrl({ uploadUrl: sig.uploadUrl, requiredHeaders: sig.requiredHeaders || {}, file, onProgress });
177
+ } else if (sig.url) {
178
+ await this._uploadToSignedForm({ uploadUrl: sig.url, fields: sig.fields || {}, file, onProgress });
167
179
  } else {
168
180
  throw new Error("No usable upload info from server");
169
181
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@applica-software-guru/didonato-storage-client",
3
- "version": "1.0.39",
3
+ "version": "1.0.41",
4
4
  "description": "Client per Didonato Storage (Node + Browser)",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.mjs",