pg-mvc-service 2.0.31 → 2.0.32
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.
|
@@ -275,7 +275,9 @@ class Base64Client {
|
|
|
275
275
|
}
|
|
276
276
|
fetchImageAsBase64(imageUrl) {
|
|
277
277
|
return __awaiter(this, void 0, void 0, function* () {
|
|
278
|
-
const res = yield axios_1.default.get(imageUrl
|
|
278
|
+
const res = yield axios_1.default.get(imageUrl, {
|
|
279
|
+
responseType: 'arraybuffer' // これを追加
|
|
280
|
+
});
|
|
279
281
|
// Content-Typeをチェック
|
|
280
282
|
const contentType = res.headers['content-type'];
|
|
281
283
|
if (!(contentType === null || contentType === void 0 ? void 0 : contentType.startsWith('image/'))) {
|
|
@@ -283,9 +285,7 @@ class Base64Client {
|
|
|
283
285
|
}
|
|
284
286
|
// ArrayBufferをBufferに変換してBase64にエンコード
|
|
285
287
|
const buffer = Buffer.from(res.data);
|
|
286
|
-
|
|
287
|
-
const mimeType = this.getMimeType(base64);
|
|
288
|
-
return `data:${mimeType};base64,${base64}`;
|
|
288
|
+
return buffer.toString('base64');
|
|
289
289
|
});
|
|
290
290
|
}
|
|
291
291
|
}
|
package/package.json
CHANGED
|
@@ -288,7 +288,9 @@ export class Base64Client {
|
|
|
288
288
|
}
|
|
289
289
|
|
|
290
290
|
public async fetchImageAsBase64(imageUrl: string): Promise<string> {
|
|
291
|
-
const res = await axios.get(imageUrl
|
|
291
|
+
const res = await axios.get(imageUrl, {
|
|
292
|
+
responseType: 'arraybuffer' // これを追加
|
|
293
|
+
});
|
|
292
294
|
|
|
293
295
|
// Content-Typeをチェック
|
|
294
296
|
const contentType = res.headers['content-type'];
|
|
@@ -298,10 +300,6 @@ export class Base64Client {
|
|
|
298
300
|
|
|
299
301
|
// ArrayBufferをBufferに変換してBase64にエンコード
|
|
300
302
|
const buffer = Buffer.from(res.data);
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
const mimeType = this.getMimeType(base64);
|
|
304
|
-
|
|
305
|
-
return `data:${mimeType};base64,${base64}`;
|
|
303
|
+
return buffer.toString('base64');
|
|
306
304
|
}
|
|
307
305
|
}
|