@golpoai/sdk 1.0.2 → 1.0.3
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 +5 -12
- package/dist/index.js +6 -13
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -839,19 +839,12 @@ var Golpo = class {
|
|
|
839
839
|
}
|
|
840
840
|
if (localFiles.length > 0) {
|
|
841
841
|
const limit = (0, import_p_limit.default)(concurrency);
|
|
842
|
-
await Promise.all(
|
|
843
|
-
localFiles.map(
|
|
844
|
-
(filePath) => limit(async () => {
|
|
845
|
-
const absPath = (0, import_path.resolve)(filePath);
|
|
846
|
-
const fileName = (0, import_path.basename)(absPath);
|
|
847
|
-
const mimeType = (0, import_mime_types.lookup)(absPath) || "application/octet-stream";
|
|
848
|
-
formData.append("uploads", (0, import_fs.createReadStream)(absPath), {
|
|
849
|
-
filename: fileName,
|
|
850
|
-
contentType: mimeType
|
|
851
|
-
});
|
|
852
|
-
})
|
|
853
|
-
)
|
|
842
|
+
const uploadedUrls = await Promise.all(
|
|
843
|
+
localFiles.map((filePath) => limit(() => this.uploadFileAndGetUrl(filePath)))
|
|
854
844
|
);
|
|
845
|
+
uploadedUrls.forEach((url) => {
|
|
846
|
+
formData.append("upload_urls", url);
|
|
847
|
+
});
|
|
855
848
|
}
|
|
856
849
|
}
|
|
857
850
|
return formData;
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/Golpo.ts
|
|
2
2
|
import axios from "axios";
|
|
3
|
-
import {
|
|
3
|
+
import { promises as fs } from "fs";
|
|
4
4
|
import { basename, resolve } from "path";
|
|
5
5
|
import { lookup as mimeLookup } from "mime-types";
|
|
6
6
|
import pLimit from "p-limit";
|
|
@@ -802,19 +802,12 @@ var Golpo = class {
|
|
|
802
802
|
}
|
|
803
803
|
if (localFiles.length > 0) {
|
|
804
804
|
const limit = pLimit(concurrency);
|
|
805
|
-
await Promise.all(
|
|
806
|
-
localFiles.map(
|
|
807
|
-
(filePath) => limit(async () => {
|
|
808
|
-
const absPath = resolve(filePath);
|
|
809
|
-
const fileName = basename(absPath);
|
|
810
|
-
const mimeType = mimeLookup(absPath) || "application/octet-stream";
|
|
811
|
-
formData.append("uploads", createReadStream(absPath), {
|
|
812
|
-
filename: fileName,
|
|
813
|
-
contentType: mimeType
|
|
814
|
-
});
|
|
815
|
-
})
|
|
816
|
-
)
|
|
805
|
+
const uploadedUrls = await Promise.all(
|
|
806
|
+
localFiles.map((filePath) => limit(() => this.uploadFileAndGetUrl(filePath)))
|
|
817
807
|
);
|
|
808
|
+
uploadedUrls.forEach((url) => {
|
|
809
|
+
formData.append("upload_urls", url);
|
|
810
|
+
});
|
|
818
811
|
}
|
|
819
812
|
}
|
|
820
813
|
return formData;
|