javascript - 如何从nodejs中Jimp库中的结果对象发送请求
问题描述
首先我的代码工作正常,但我正在努力改进它,只是我试图从主机请求一个图像文件,然后用 Jimp 调整它的大小,最后将它上传到我的 Cloudinary 帐户。但在将其发送到 Cloudinary 之前,我实际上在我的办公桌上保留了一份副本,然后引用了该名称。所以我需要知道如何使用来自 Jimp 函数的图像结果,然后将其发送到 Cloudinary 而不在我的驱动器上保留副本?
let imgURL =
"https://s3-eu-central-1.amazonaws.com/salla-cdn/FY1gllCm5QiMxstupKHqCkNOWuUxWn0jYqrBLrFI.jpeg";
const imgArr = imgURL.split("/");
const imageName = imgArr[imgArr.length - 1];
Jimp.read(imgURL)
.then(image => {
image.resize(500, 500).write(`./ready/${imageName}`);//RESIZING DONE
//START UPLOADING
cloudinary.uploader.upload(
`./ready/${imageName}`,
{
crop: "limit",
tags: "samples",
use_filename: true,
unique_filename: false
},
function(result) {
console.log(result);
}
);
})
.catch(err => {
console.log(err);
});
解决方案
推荐阅读
- powershell - PowerShell 类;属性“System.Collections.Specialized.OrderedDictionary”;如何添加字典条目
- java - 如何让 Visual Studio 识别 Spring Boot 包并获得 IntelliSense?
- actions-on-google - 在 dialogflow 和 AoG 中同时运行代码,但由于 userStorage 而无法这样做
- excel - 通过 excel vba 脚本和 bexanalyzer 静默登录到 sap bw 服务器
- python - 在分组的 Pandas 数据框中删除最大值后的行
- riscv - 如何为 RISC-V Rocket-Chip 创建 SystemC 代码?
- vuejs2 - 如何聚焦和激活 vue 多选?
- ssl - '连接到 Podio API 失败:[35] 连接到 api.podio.com:443 时出现未知 SSL 协议错误
- java - java.io.IOException: error=12, 无法分配内存
- android - appcompat-v7:27.1.1 CardView 未在以前的 api 中显示