如何将文件上传到 Backblaze 上的特定文件夹?

How to upload file into a specific folder on Backblaze?

哟!所以我关注了this guide on Backblaze and 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
    });
};

好吧,我觉得自己很蠢。解决方案很简单:

"X-Bz-File-Name": "folderName/" + fileName,

我之前是通过Backblaze界面创建的文件夹,所以路径已经存在。 哟.