Ios 使用开源解析服务器在解析中删除PFFile时遇到问题
我有一个包含图像引用的集合,当用户使用新图像更新该集合时,我希望删除旧图像。我保留对URL的引用,以便将旧图像传递到云代码中编写的函数中 我在我的计算机上运行所有这些本地操作,但是当我在Heroku上运行服务器时,我会遇到同样的问题。这是从iOS SDK调用的 以下是所讨论的功能:Ios 使用开源解析服务器在解析中删除PFFile时遇到问题,ios,rest,parse-platform,Ios,Rest,Parse Platform,我有一个包含图像引用的集合,当用户使用新图像更新该集合时,我希望删除旧图像。我保留对URL的引用,以便将旧图像传递到云代码中编写的函数中 我在我的计算机上运行所有这些本地操作,但是当我在Heroku上运行服务器时,我会遇到同样的问题。这是从iOS SDK调用的 以下是所讨论的功能: Parse.Cloud.define('removeOldFilesFromDB', function (request, response) { var fileUrls = request.params
Parse.Cloud.define('removeOldFilesFromDB', function (request, response) {
var fileUrls = request.params.fileUrls;
var promises = [];
for (var a = 0; a < fileUrls.length; a++) {
promises.push(Parse.Cloud.httpRequest({
method: 'DELETE',
url: fileUrls[a],
headers: {
'X-Parse-Application-Id': process.env.APP_ID || 'myAppId',
'X-Parse-Master-Key': process.env.MASTER_KEY || 'myMasterKey'
}
}));
}
Parse.Promise.when(promises).then( function (result) {
console.log("Successfully deleted files");
response.success(result);
}, function(a,b,c,d,e) {
console.log("Nope jacked it up!");
response.error("Error deleting files");
});
})
所以奇怪的是,删除呼叫甚至没有出现在那里。我是不是用Parse.Cloud.httpRequest方法错了
如果我在浏览器中点击fileUrl的值,它会下载我试图删除的图像,以便路径正确
这是parse server的最新发布版本2.2.10
以下是我遵循的说明,我认为这是正确的方法:
下面是从云代码进行rest调用的步骤:
根据这一点,它说我可以使用Parse.Cloud.httpRequest进行REST调用,所以我不确定您指的是什么,因为这不是正确的方法。这两个都有指向文档的链接,这就是我所遵循的
所以我显然做错了什么,但我不确定是否有人能帮上忙?只需从文件URL中删除myAppId即可 (例如) 从 /myAppId/7b5b50e2871af27971be0425f367ab96_file.bin 到
只需从文件URL中删除myAppId即可 (例如) 从 /myAppId/7b5b50e2871af27971be0425f367ab96_file.bin 到
实际上,我们最终完全从后端删除了解析,这是一个更好的解决方案:)您选择了哪种解决方案而不是解析?我们最终没有使用任何现成的解决方案,而是使用我们自己的node.js服务器。现在解析不存在了,开销大大减少了,而且更安全,因为我们可以100%控制一切。实际上,我们最终从后端完全删除了解析,更好的解决方案:)您选择了哪种解决方案而不是解析?我们最终没有使用任何现成的解决方案,而是使用我们自己的node.js服务器。现在解析不存在了,开销大大减少了,而且它也更加安全,因为我们可以100%控制一切。
verbose: POST /parse/functions/removeOldFilesFromDB { host: 'e0ae0682.ngrok.io',
'x-parse-client-version': 'i1.12.0',
accept: '*/*',
'x-parse-session-token': 'r:5290c76c47678213770765d990ee38b6',
'x-parse-application-id': 'myAppId',
'x-parse-client-key': 'myClientKey',
'x-parse-installation-id': '3fafc219-1c63-4d68-b42f-5caa3e1c27cb',
'accept-language': 'en-us',
'accept-encoding': 'gzip, deflate',
'x-parse-os-version': '8.1 (12B411)',
'content-type': 'application/json; charset=utf-8',
'content-length': '204',
'user-agent': 'Spin%20the%20Bottle/1 CFNetwork/711.1.12 Darwin/14.0.0',
'x-parse-app-build-version': '1',
'x-parse-app-display-version': '1.0',
'x-forwarded-for': '71.163.238.223' } {
"fileUrls": [
"http://e0ae0682.ngrok.io/parse/files/myAppId/7b5b50e2871af27971be0425f367ab96_file.bin",
"http://e0ae0682.ngrok.io/parse/files/myAppId/cff909602b60b15331b1ac60a4f08697_file.bin"
]
}
Nope jacked it up!
verbose: error: code=141, message=Error deleting files