0
我已成功上傳一個圖像到亞馬遜s3與這個流星包 https://github.com/Lepozepo/S3現在我想刪除文件,我得到一個錯誤。流星亞馬遜s3刪除圖像
這是s3.delete代碼
S3.delete(路徑,回調)
此功能會永久破壞位於您的S3存儲桶文件的文檔。
參數:
路徑:必須是這種格式( 「/folder/other_folder/file.extension」)。 所以基本上總是以「/」開頭,並且永遠以「/」結尾。這是需要的 。
回調函數:在刪除操作 完成後運行的函數返回一個錯誤作爲第一個參數(如果存在 ),並且結果作爲第二個參數。
這是我上傳和刪除代碼
Template.postSubmit.events({
"click button.upload": function(){
var files = $("input.file_bag")[0].files
S3.upload({
files:files,
path:"uploads"
},function(e,r){
console.log(r);
delete_url = r.relative_url;
console.log(delete_url);
});
},
"click button.delete": function(){
S3.delete({
path:delete_url
},function(e,r){
console.log(e);
console.log(r);
});
}
});
擊中刪除按鈕,當我得到的錯誤。
errorClass {isClientSafe: true, error: 400, reason: "Match failed", details: undefined, message: "Match failed [400]", …}
details
:
undefined
error
:
400
errorType
:
"Meteor.Error"
isClientSafe
:
true
message
:
"Match failed [400]"
reason
:
"Match failed"
stack
:
"Error↵ at Connection._livedata_result (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:4823:23)↵ at onMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:3528:206)↵ at http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:2908:9↵ at Array.forEach (<anonymous>)↵ at Function._.each._.forEach (http://localhost:3000/packages/underscore.js?hash=cde485f60699ff9aced3305f70189e39c665183c:149:11)↵ at SockJS.self.socket.onmessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:2907:43)↵ at SockJS.REventTarget.dispatchEvent (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:142:28)↵ at SockJS._dispatchMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1309:14)↵ at SockJS._didMessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1375:26)↵ at WebSocket.that.ws.onmessage (http://localhost:3000/packages/ddp-client.js?hash=14d966b7972bd95a1f7015fec9ac340f10508a44:1531:21)"
__proto__
:
Error
更新 這是我在終端側
Exception while invoking method '_s3_delete' Error: Match error: Expected string, got object
您可以在上傳之前和刪除之前插入'console.log(delete_url);'? – Styx
是的,我可以,並且正如文檔所要求的那樣,它給了我路徑'/ uploads/image-name.jpg'。 –