mirror of
https://github.com/EvolutionAPI/evolution-api.git
synced 2026-01-09 21:32:20 -06:00
feat: send media with form-data
This commit is contained in:
@@ -70,7 +70,6 @@ import { BadRequestException, InternalServerErrorException, NotFoundException }
|
||||
import ffmpegPath from '@ffmpeg-installer/ffmpeg';
|
||||
import { Boom } from '@hapi/boom';
|
||||
import { Instance } from '@prisma/client';
|
||||
import { deleteTempFile, getTempFile } from '@utils/getTempFile';
|
||||
import { makeProxyAgent } from '@utils/makeProxyAgent';
|
||||
import { getOnWhatsappCache, saveOnWhatsappCache } from '@utils/onWhatsappCache';
|
||||
import useMultiFileAuthStatePrisma from '@utils/use-multi-file-auth-state-prisma';
|
||||
@@ -2270,7 +2269,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
public async statusMessage(data: SendStatusDto, file?: any) {
|
||||
const mediaData: SendStatusDto = { ...data };
|
||||
|
||||
if (file) mediaData.content = await getTempFile(file, this.instanceId);
|
||||
if (file) mediaData.content = file.buffer.toString('base64');
|
||||
|
||||
const status = await this.formatStatusMessage(mediaData);
|
||||
|
||||
@@ -2278,8 +2277,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
status,
|
||||
});
|
||||
|
||||
if (file) await deleteTempFile(file, this.instanceId);
|
||||
|
||||
return statusSent;
|
||||
}
|
||||
|
||||
@@ -2407,7 +2404,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
public async mediaSticker(data: SendStickerDto, file?: any) {
|
||||
const mediaData: SendStickerDto = { ...data };
|
||||
|
||||
if (file) mediaData.sticker = await getTempFile(file, this.instanceId);
|
||||
if (file) mediaData.sticker = file.buffer.toString('base64');
|
||||
|
||||
const convert = await this.convertToWebP(data.sticker);
|
||||
const gifPlayback = data.sticker.includes('.gif');
|
||||
@@ -2426,15 +2423,13 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
},
|
||||
);
|
||||
|
||||
if (file) await deleteTempFile(file, this.instanceId);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async mediaMessage(data: SendMediaDto, file?: any, isIntegration = false) {
|
||||
const mediaData: SendMediaDto = { ...data };
|
||||
|
||||
if (file) mediaData.media = await getTempFile(file, this.instanceId);
|
||||
if (file) mediaData.media = file.buffer.toString('base64');
|
||||
|
||||
const generate = await this.prepareMediaMessage(mediaData);
|
||||
|
||||
@@ -2451,8 +2446,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
isIntegration,
|
||||
);
|
||||
|
||||
if (file) await deleteTempFile(file, this.instanceId);
|
||||
|
||||
return mediaSent;
|
||||
}
|
||||
|
||||
@@ -2560,7 +2553,7 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
public async audioWhatsapp(data: SendAudioDto, file?: any, isIntegration = false) {
|
||||
const mediaData: SendAudioDto = { ...data };
|
||||
|
||||
if (file) mediaData.audio = await getTempFile(file, this.instanceId);
|
||||
if (file) mediaData.audio = file.buffer.toString('base64');
|
||||
|
||||
if (!data?.encoding && data?.encoding !== false) {
|
||||
data.encoding = true;
|
||||
@@ -2581,8 +2574,6 @@ export class BaileysStartupService extends ChannelStartupService {
|
||||
isIntegration,
|
||||
);
|
||||
|
||||
if (file) await deleteTempFile(file, this.instanceId);
|
||||
|
||||
return result;
|
||||
} else {
|
||||
throw new InternalServerErrorException('Failed to convert audio');
|
||||
|
||||
Reference in New Issue
Block a user