【发布时间】:2019-05-15 07:50:03
【问题描述】:
我需要编写一些代码,在 Facebook Messenger 中获取图片网址并将其转换为图片。
但是,使用 image-to-base64 或 fetch-base64 将不起作用,因为 facebook 有效负载 url 在其末尾有时间戳,而这些工具要求 url 以 .jpg 或 .png 结尾。
网址格式:
https://scontent.fhan2-4.fna.fbcdn.net/v/t1.15752-0/p480x480/60251115_627131164420267_474161086648549376_n.png?_nc_cat=100&_nc_oc=AQmldFK_xUgJPT-rqrk4bxLivk8ispusU5THY7br4ZpvNTfcYVrfU-rBFlIX9cwUzaw&_nc_ht=scontent.fhan2-4.fna&oh=140ea3424f8fa6a9085b3ae88281fa51&oe=5D5F4DAD
我尝试过使用 image-to-base64 和 fetch-base6,但它们都不起作用。
const image2base64 = require('image-to-base64');
module.exports = (string) => {
console.log(string);
image2base64(string) // you can also to use url
.then(
(response) => {
console.log(response);
}
)
.catch(
(error) => {
console.log(error);
}
)
}
我想获得base64结果,所以我想知道是否有任何包可以帮助我完成这项任务。
【问题讨论】:
-
您可以先使用 Axios 临时存储图像,然后从那里开始。
-
Facebook 似乎并不介意您在 URL 的末尾附加
&_foo=.jpg之类的东西 - 也许这已经足以“欺骗”这些工具了……?
标签: javascript node.js image facebook base64