如何通过ruby API删除cloudinary帐户中的所有图像?
是否有通过该delete_resource_by_tag方法删除所有资源的特殊标志?
例如
Cloudinary::Api::delete_resources_by_tag "all"
Run Code Online (Sandbox Code Playgroud) 我已经做了一些查看Cloudinary API并上传NodeJS的示例,看起来服务器端上传使用文件路径.同时,客户端上传需要前端输入标记.我已经有一个前端供用户根据自己的喜好选择和裁剪图片,这给了我一个数据URI.我想将此文件保存到Cloudinary,而无需使用其内置的前端选项.这可能吗?这基本上意味着我可以调用某种可以获取URI或文件blob的上传函数.
我在上传到正确的文件夹时遇到了一些困难。如果我指定:
cloudinary.uploader.upload(filePath, {
folder: 'test-directory'
});
Run Code Online (Sandbox Code Playgroud)
我正在关注节点集成指南:http : //cloudinary.com/documentation/image_upload_api_reference#upload
我提前创建了“测试目录”。图像上传成功,但总是进入我的媒体库的根目录。
我在我的帐户设置中启用了“自动创建文件夹”。
这是来自 Cloudinary 的示例上传响应:
{
public_id: 'we1yjvlpxc1qtuf1oaqe',
version: 1503236713,
signature: '37edbc2b19ea72b75298acce8075f9e8ddb12d09',
width: 675,
height: 37,
format: 'jpg',
resource_type: 'image',
created_at: '2017-08-20T13:45:13Z',
tags: [],
bytes: 602,
type: 'upload',
etag: 'b5522ae652340881b213c46c035d0aed',
url: 'http://res.cloudinary.com/alsoicode/image/upload/v1503236713/we1yjvlpxc1qtuf1oaqe.jpg',
secure_url: 'https://res.cloudinary.com/alsoicode/image/upload/v1503236713/we1yjvlpxc1qtuf1oaqe.jpg',
original_filename: 'test_r6_c1'
}
Run Code Online (Sandbox Code Playgroud)
我也尝试将文件夹名称添加到public_id选项中,但这也不起作用。
我究竟做错了什么?
我在带有Cloudinary包的Django应用中定义了如下图像上传,
class Photo(models.Model):
photo = CloudinaryField('image')
Run Code Online (Sandbox Code Playgroud)
我想使该字段上载多幅图像。我该怎么做呢?
我需要确保客户端上传到cloudinary的安全,以便我使用cloudinary api_secret密钥和时间从节点服务器端生成签名令牌,使用此代码
api_sign_request = function(params_to_sign, api_secret)。在这些之后,如何使用此令牌将图像从前端上传到 cloudinary
上传和设置默认控制器功能运行良好。然而,我们也正在尝试实现从 Cloudinary 删除图像。如何做呢?在文档中它很混乱。这是代码:
const cloudinary = require('cloudinary');
const HttpStatus = require('http-status-codes');
const User = require('../models/userModels');
cloudinary.config({
cloud_name: 'name',
api_key: 'key',
api_secret: 'secret'
});
module.exports = {
UploadImage(req, res) {
cloudinary.uploader.upload(req.body.image, async result => {
await User.update(
{
_id: req.user._id
},
{
$push: {
images: {
imgId: result.public_id,
imgVersion: result.version
}
}
}
)
.then(() =>
res
.status(HttpStatus.OK)
.json({ message: 'Image uploaded successfully' })
)
.catch(err =>
res
.status(HttpStatus.INTERNAL_SERVER_ERROR)
.json({ message: 'Error uploading image' })
);
});
},
DeleteImage(req, res) { …Run Code Online (Sandbox Code Playgroud) 我正在尝试将图像作为电子邮件的附件发送,但我无法弄清楚如何完成此操作。
我使用 Mailgun 发送邮件,使用 Cloudinary 上传图像,使用 MongoDB 作为我的数据库,使用 Node.js/Express 作为我的后端。
用户流程是这样的:
显然这并不理想,因为您需要单独单击每个链接才能查看和下载图像。我想将它们直接附加到电子邮件中,以便用户可以更轻松地下载图像。
我已经查看了 Mailgun 的文档,但似乎不能将非本地图像作为附件发送。有什么我想念的吗?
我曾尝试为 Mailgun 使用“内联”和“附件”参数,但最终得到一条错误消息,指出无法找到文件/目录。
var pictures = [];
post.images.forEach(function(photos){
pictures.push(photos + " ");
return pictures;
});
var attch = new mailgun.Attachment({data: pictures[0], filename: "picture"});
var data = {
from: "email <email@email.com>",
to: "email@email.com",
subject: 'this is an email',
html: 'here is a new post and here are the images in that post',
attachment: attch
};
Run Code Online (Sandbox Code Playgroud)
预期的结果是一封带有新帖子附加图像的电子邮件,或者在这种情况下是来自该帖子的单个图像。
实际结果是这个错误信息: …
我尝试使用 cloudinary API_URL 直接从我的前端(Angular 8)上传文件,但仍然收到相同的错误请求(400)和相同的错误“上传预设必须列入未签名上传的白名单”,即使我尝试了不同的解决方案,例如在 FormData 中提供预设名称,并在我的 cloudinary 设置中将预设设置为无符号,但仍然无法正常工作。有什么解决办法吗?
我的上传代码:
const images = new FormData();
images.append('images', file);
images.append('upload_preset', [presetName]);
this.progressBar = true
const req = new HttpRequest('POST', 'https://api.cloudinary.com/v1_1/[cloudName]/image/upload', images,
{
reportProgress: true,
});
this.http.request(req).subscribe(event => {
if (event.type === HttpEventType.UploadProgress) {
const percentDone = Math.round(100 * event.loaded / event.total);
console.log(`File is ${percentDone}% uploaded.`);
} else if (event instanceof HttpResponse) {
console.log('File is completely uploaded!');
}
});
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用在 cloudinary 上上传的公共 url 访问 pdf,但是 url 请求已成功完成,但没有显示任何内容。
权限:在 cloudinary 上的 pdf 属性中阻止传递显示
我正在尝试设置 Cloudinary 的上传小部件并将生成的 Cloudinary 对象保存到CloudinaryField()我的模型中。Cloudinary 的示例项目仅展示了如何使用{{form}}.
当我使用小部件上传时,我得到了一本字典,但我在文档中找不到任何地方可以让我保存它。
cloudinary ×10
node.js ×4
django ×2
express ×2
angular8 ×1
http ×1
httprequest ×1
javascript ×1
jquery ×1
mailgun ×1
mongodb ×1
mongoose ×1
pdf ×1
python ×1
ruby ×1