@sparkelf/dsh-dataops-managed 0.3.50 → 0.3.51
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/lib/client.js +165 -155
- package/lib/client.js.map +1 -1
- package/lib/index.js +10 -1
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -1312,6 +1312,15 @@ const readCollectFile = async (filePath) => {
|
|
|
1312
1312
|
sizeBytes: info.size
|
|
1313
1313
|
};
|
|
1314
1314
|
};
|
|
1315
|
+
/** Multipart part MIME from the spreadsheet extension; Blob defaults to octet-stream otherwise. */
|
|
1316
|
+
function spreadsheetMimeType(fileName) {
|
|
1317
|
+
const extension = fileName.includes(".") ? fileName.split(".").pop()?.toLowerCase() ?? "" : "";
|
|
1318
|
+
if (extension === "csv") return "text/csv";
|
|
1319
|
+
if (extension === "tsv") return "text/tab-separated-values";
|
|
1320
|
+
if (extension === "xlsx") return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
|
|
1321
|
+
if (extension === "xls") return "application/vnd.ms-excel";
|
|
1322
|
+
return "application/octet-stream";
|
|
1323
|
+
}
|
|
1315
1324
|
/** Spreadsheet import calls bound to one workspace credential. */
|
|
1316
1325
|
var CollectApi = class {
|
|
1317
1326
|
reviewApi;
|
|
@@ -1321,7 +1330,7 @@ var CollectApi = class {
|
|
|
1321
1330
|
async preview(filePath) {
|
|
1322
1331
|
const file = await readCollectFile(filePath);
|
|
1323
1332
|
const form = new FormData();
|
|
1324
|
-
form.append("file", new Blob([new Uint8Array(file.buffer)]), file.fileName);
|
|
1333
|
+
form.append("file", new Blob([new Uint8Array(file.buffer)], { type: spreadsheetMimeType(file.fileName) }), file.fileName);
|
|
1325
1334
|
const result = await this.reviewApi.request("/api/resources/spreadsheet-import/preview", {
|
|
1326
1335
|
method: "POST",
|
|
1327
1336
|
body: form
|
package/package.json
CHANGED