await client.setPicture(phoneNumber, imagePath)
Keeps loading forever and not works.
fica somente lendo e não da resultado. A função não funciona.
Explicação
**Set Picture
Set image for profile or group
//number of chat, file local path
let response = await client.setPicture("5561981590153", "./image-profile.png")**
Codig:
_let result = await client.setPicture(phoneNumber, imagePath);
// Update Profile Photo
app.post(/${sessionName}/update-profile-photo, async (req, res) => {
const { phoneNumber, url } = req.body;
try {
// Baixar a imagem da URL
const response = await axios({ url, responseType: 'arraybuffer' });
// Gerar um caminho absoluto para o arquivo
const imagePath = path.resolve(__dirname, `profile-${Date.now()}.jpg`);
// Salvar a imagem localmente
fs.writeFileSync(imagePath, response.data);
// Verificar se o arquivo foi salvo corretamente antes de enviar
if (!fs.existsSync(imagePath)) {
throw new Error('Arquivo não foi salvo corretamente.');
}
// Atualizar a foto de perfil
let result = await client.setPicture(phoneNumber, imagePath);
console.log(result);
res.json(`Atualizada foto perfil da sessão ${sessionName}!`);
// Remover o arquivo após o uso
fs.unlinkSync(imagePath);
} catch (error) {
console.error(`Erro ao atualizar foto perfil sessão ${sessionName}:`, error);
res.status(500).json("Erro ao atualizar foto perfil sessão");
}
});
await client.setPicture(phoneNumber, imagePath)
Keeps loading forever and not works.
fica somente lendo e não da resultado. A função não funciona.
Explicação
**Set Picture
Set image for profile or group
//number of chat, file local path
let response = await client.setPicture("5561981590153", "./image-profile.png")**
Codig:
_let result = await client.setPicture(phoneNumber, imagePath);
// Update Profile Photo
app.post(/${sessionName}/update-profile-photo, async (req, res) => {
const { phoneNumber, url } = req.body;
});