如何通过uploadcare中的rest api删除文件 [英] How to delete file/s through rest api in uploadcare

查看:70
本文介绍了如何通过uploadcare中的rest api删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用jquery ajax删除uploadcare rest api中的文件。
这是我目前的jquery代码:

I'm trying to delete file/s in uploadcare rest api using jquery ajax. Here is my current codes for jquery:

$.ajax({
            url: "http://api.uploadcare.com/files/" + $("#photoguid").val() + "/",
            type: "DELETE",
            contentType: "application/json"
});

我的问题是如何正确实现它,因为每次调用它时,它都会重定向到登录页面这是我在查询提琴手时看到的内容,我不知道在何处放置授权。我只是为此使用免费试用版。

My question is how to implement it properly because every time I call this, it redirects me to login page, that's what I see when checking in fiddler and I'm not sure where to put the authorization. I'm only using free trial for this.

推荐答案

文档确实说必须通过https进行休息调用。 https://uploadcare.com/documentation/rest/

The docs do say Rest calls must be done via https. https://uploadcare.com/documentation/rest/

至于请求标题看起来像是在这里得到解答:
如何使用js或jQuery向ajax请求添加自定义HTTP标头?

As for the request headers looks like that was answered here: How can I add a custom HTTP header to ajax request with js or jQuery?

以下是您案例的示例:

$.ajax({
    url: "https://api.uploadcare.com/files/" + $("#photoguid").val() + "/",
    type: "DELETE",
    headers: { "Authorization": "Uploadcare.Simple demopublickey:demoprivatekey" }
});

自2014-12-24以来,Uploadcare API允许交叉原始请求,因此如果您要公开你的私钥或想要向你的后端添加往返以获得正确的身份验证标头值,去吧。

Since 2014-12-24, Uploadcare API allows cross origin requests so if you're up to exposing your private key or want to add roundtrip to your backend to get proper Authentication header value, go for it.

这篇关于如何通过uploadcare中的rest api删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆