查看文档,有两种方法可以使用node.js sdk将文件(图像,视频等)上传到cloudinary。
使用以下指定的方法之一时,是否可以通过某种方式获取进度报告?例如,已上传100MB的1个。
cloudinary.v2.uploader.upload_large(filePath, options, (err, results) => {});
cloudinary.v2.uploader.upload(filePath, options, (err, results) => {});
对于大于此限制(100MB)的资产,您必须要求在请求派生版本之前创建派生版本(我们称之为“急切”,并且在后台(“异步”)进行处理)。当使用异步eager转换时,您可以操纵与帐户的最大视频/图像文件大小限制一样大的资产。
可以在upload API call中为新资产请求快速转换,或者在upload preset中对其进行配置,包括在上传到媒体库时使用的上传预设。对于现有视频,您可以通过explicit API方法请求急切的转换。视频急切/异步转换后,将照常通过URL进行播放。
例如,在节点中:
cloudinary.v2.uploader.upload("sample.jpg",
{ eager: [
{ width: 300, height: 300, crop: "pad" },
{ width: 160, height: 100, crop: "crop", gravity: "south"} ],
eager_async: true,
eager_notification_url: "https://mysite.example.com/eager_endpoint",
notification_url: "https://mysite.example.com/upload_endpoint" },
function(error, result) {console.log(result, error); });