mimamch / wa-gateway

Headless Multi Session Whatsapp Gateway API
MIT License
206 stars 106 forks source link

kirim file dll #23

Open Nawkhi opened 1 year ago

Nawkhi commented 1 year ago

bisakah untuk kirim file atau yang lainnya gan.?

mimamch commented 1 year ago

next update yap

Nawkhi commented 1 year ago

ok bang di tunggu

Nawkhi commented 1 year ago

exports.sendPdf = async (req, res, next) => { try { let to = req.body.to || req.query.to; let media = req.body.media || req.query.media; let isGroup = req.body.isGroup || req.query.isGroup; const sessionId = req.body.session || req.query.session || req.headers.session;

if (!to || !media) throw new ValidationError("Missing Parameters");

const receiver = to;
const filename = media;
const document = fs.readFileSync(media); // return Buffer

if (!sessionId) throw new ValidationError("Session Not Founds");
const send = await whatsapp.sendDocument({
  sessionId,
  to: receiver,
  isGroup: !!isGroup,
  filename: filename,
  media: document,
});

res.status(200).json(
  responseSuccessWithData({
    id: send?.key?.id,
    status: send?.status,
    message: send?.message?.extendedTextMessage?.caption || "Not Text",
    remoteJid: send?.key?.remoteJid,
  })
);

} catch (error) { next(error); } };

Nawkhi commented 1 year ago

medianya lewat url bagaimana bang.??

mimamch commented 1 year ago

Untuk File baru bisa via Buffer, untuk url baru bisa image dan video

Nawkhi commented 1 year ago

Sudah bisa bang pakai axios Terimakasih ya bang Coding abang sangat membantu. 🙏🙏🙏

mdestafadilah commented 1 year ago

Sudah bisa bang pakai axios Terimakasih ya bang Coding abang sangat membantu. 🙏🙏🙏

gimana gimana? bisa dishare pak?

mrnoobnoobies commented 1 day ago

Sudah bisa bang pakai axios Terimakasih ya bang Coding abang sangat membantu. 🙏🙏🙏

mohon share gimana cara 🙏