删除ParseFile

时间:2015-11-30 14:41:29

标签: android parse-platform libgdx

用户可以将图像上传到后端服务器。我希望他们能够删除和替换它们。我已经明白我无法使用SDK来执行此操作。这是它的HTTP请求。 这是我到目前为止所得到的。但是我无法将它组合在一起并编写实际的删除方法。

private String parseURL = "https://api.parse.com";
private String appID = ".....";
private String parseAppID = "X-Parse-Application-Id";
private String masterKey = ".....";
private String parseMasterKey="X-Parse-Master-Key";
Net.HttpRequest http;

private String IMAGE1 = "***.png";
private String IMAGE2 = "***.png";

    http = new Net.HttpRequest(Net.HttpMethods.GET);
    http.setUrl(parseURL);
    http.setMethod("DELETE");
    http.setHeader(parseAppID,appID);
    http.setHeader(parseMasterKey,masterKey);

我找到了关于JavaScript的工作示例。

1 个答案:

答案 0 :(得分:3)

如果您确实需要这样做,可以使用以下 Cloud Code 使用主密钥进行REST api调用以删除文件:

Parse.Cloud.httpRequest({
  url: 'https://api.parse.com/1/files/FILE.png',
  method: 'DELETE',
  headers: {
    'X-Parse-Application-Id': 'abcd1234',
    'X-Parse-Master-Key':     'abcd1234'
  }
}).then(function(httpResponse) {
  console.log(httpResponse.text);
}, function(httpResponse) {
   console.error('Request failed with response code ' + httpResponse.status);
});