fix: upload for product

This commit is contained in:
Adhiraj Singh
2022-09-02 20:09:54 +05:30
parent 9e581f59cb
commit 765dcc1d1f
5 changed files with 24 additions and 10 deletions

View File

@@ -210,7 +210,11 @@ export async function uploadingNecessaryImagesOfProduct<T extends ProductUpdate
/**
* Uploads images not already uploaded to WA's servers
*/
export const uploadingNecessaryImages = async(images: WAMediaUpload[], waUploadToServer: WAMediaUploadFunction, timeoutMs = 30_000) => {
export const uploadingNecessaryImages = async(
images: WAMediaUpload[],
waUploadToServer: WAMediaUploadFunction,
timeoutMs = 30_000
) => {
const results = await Promise.all(
images.map<Promise<{ url: string }>>(
async img => {
@@ -234,7 +238,11 @@ export const uploadingNecessaryImages = async(images: WAMediaUpload[], waUploadT
const { mediaUrl } = await waUploadToServer(
toReadable(Buffer.concat(contentBlocks)),
{ mediaType: 'image', fileEncSha256B64: sha, timeoutMs }
{
mediaType: 'product-image',
fileEncSha256B64: sha,
timeoutMs
}
)
return { url: mediaUrl }
}