哟!因此,我遵循了有关 Backblaze 和 JavaScript 的本指南。我已经在我的 Backblaze 存储桶上成功上传了文件,但我找不到一种方法来定义上传文件的文件夹。
我还检查了文档,它提到了文件夹,但没有在上传文件的竞赛中。有人知道怎么做吗?
{
axios
.post(
credentials.apiUrl + "/b2api/v1/b2_get_upload_url",
{
bucketId: bucketId,
},
{ headers: { Authorization: credentials.authorizationToken } }
)
.then(function (response) {
var uploadUrl = response.data.uploadUrl;
var uploadAuthorizationToken = response.data.authorizationToken;
const fileSize = file.byteLength;
var sha1 = crypto.createHash("sha1").update(file).digest("hex");
axios
.post(uploadUrl, file, {
headers: {
Authorization: uploadAuthorizationToken,
"X-Bz-File-Name": fileName,
"Content-Type": "b2/x-auto",
"Content-Length": fileSize,
"X-Bz-Content-Sha1": sha1,
"X-Bz-Info-Author": "unknown",
},
})
.then(function (response) {
console.log(response); // successful response
})
.catch(function (err) {
console.log(err); // an error occurred
});
})
.catch(function (err) {
console.log(err); // an error occurred
});
};