Skip to content

Commit de2d225

Browse files
committed
fix(tiny-erp): Fix uploading images when importing new products from Tiny
Remove manual content headers on upload request (axios sets automatically) and properly setup blob on form data Increasing timeouts for both image download and upload requests
1 parent d4f07fe commit de2d225

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

packages/apps/tiny-erp/src/integration/parsers/product-from-tiny.ts

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,24 +33,22 @@ const tryImageUpload = async (
3333
ecomAccessToken = data.access_token;
3434
}
3535
try {
36-
const { data, headers } = await axios.get(originImgUrl, {
36+
const { data } = await axios.get(originImgUrl, {
3737
responseType: 'arraybuffer',
38-
timeout: 10000,
38+
timeout: 20000,
3939
});
4040
const formData = new FormData();
41-
formData.append('file', new Blob(data), originImgUrl.replace(/.*\/([^/]+)$/, '$1'));
41+
formData.append('file', new Blob([data]), originImgUrl.replace(/.*\/([^/]+)$/, '$1'));
4242
const {
4343
data: { picture },
4444
status,
4545
} = await axios.post('https://ecomplus.app/api/storage/upload.json', formData, {
4646
headers: {
47-
'Content-Type': headers['Content-Type'],
48-
'Content-Length': headers['Content-Length'],
4947
'X-Store-ID': storeId,
5048
'X-My-ID': authenticationId,
5149
'X-Access-Token': ecomAccessToken,
5250
},
53-
timeout: 35000,
51+
timeout: 60000,
5452
});
5553
if (picture) {
5654
Object.keys(picture).forEach((imgSize) => {

packages/apps/tiny-erp/src/tiny-erp.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export const tinyerp = {
2222
.runWith({
2323
...httpsFunctionOptions,
2424
memory: '512MB',
25+
timeoutSeconds: 180,
2526
})
2627
.https.onRequest((req, res) => {
2728
return createExecContext(() => handleTinyWebhook(req, res));

0 commit comments

Comments
 (0)