@swan-admin/swan-ai-measurements 1.0.87 → 1.0.88

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swan-admin/swan-ai-measurements",
3
- "version": "1.0.87",
3
+ "version": "1.0.88",
4
4
  "description": "provides ai measurement suggestion",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",
package/src/fileUpload.ts CHANGED
@@ -120,8 +120,11 @@ export default class FileUpload {
120
120
  contentType: file.type,
121
121
  objectMetadata: arrayMetaData,
122
122
  },
123
+ throwError: true,
123
124
  });
125
+ console.log(res, "res for start");
124
126
  const totalChunks = getFileChunks(file);
127
+ console.log(totalChunks, "total chunks");
125
128
  for (let i = 0; i < totalChunks.length; i++) {
126
129
  const data: { url: string } = await fetchData({
127
130
  path: FILE_UPLOAD_ENDPOINT.UPLOAD_SIGN_PART,
@@ -131,12 +134,14 @@ export default class FileUpload {
131
134
  uploadId: res?.uploadId,
132
135
  partNumber: i + 1,
133
136
  },
137
+ throwError: true,
134
138
  });
139
+ console.log(data, "data for signed url");
135
140
  await axios.put(data?.url, totalChunks[i], { headers: { "Content-Type": file.type, "X-Api-Key": this.#accessKey } });
136
141
  }
137
142
  return { message: "successfully uploaded" };
138
143
  } catch (error: any) {
139
- throw new Error(`Failed to upload: ${error?.message}`);
144
+ throw new Error(`Failed to upload: ${error?.message || "something went wrong"}`);
140
145
  }
141
146
  }
142
147
  }
package/src/utils.ts CHANGED
@@ -36,7 +36,7 @@ export async function fetchData(options: FetchDataOptions): Promise<any> {
36
36
  } catch (error: any) {
37
37
  console.error(error, "while uploading");
38
38
  if (throwError) {
39
- throw new Error(`Failed to upload: ${error.message}`);
39
+ throw new Error(`Failed to upload: ${error?.message || "something went wrong"}`);
40
40
  }
41
41
  return {};
42
42
  }