Closed mattfranciswork0 closed 2 years ago
The URL returned is not to be used before uploading, but for uploading. Use the uploadUrl
and the authorizationToken
to upload your image with a POST
request.
See https://www.backblaze.com/b2/docs/b2_upload_file.html for more details
You can construct the download URL according to the mechanism documented at b2_download_file_by_name:
The base URL to use comes from the b2_authorize_account call, and looks something like https://f345.backblazeb2.com. The "f" in the URL stands for "file", and the number is the cluster number containing your account. To this base, you add "file/", your bucket name, a "/", and then the name of the file. The file name may itself include more "/" characters.
If you have a bucket named "photos", and a file called "cute/kitten.jpg", then the URL for downloading that file would be: https://f345.backblazeb2.com/file/photos/cute/kitten.jpg.
In terms of backblaze-b2, this is simply:
const auth = await b2.authorize();
const downloadURL = auth.data.downloadUrl + '/file/' + bucketName + '/' + fileName;
Same issue i have.. i can able to upload file, i have to store download url somewhere in database
@varundeva Read my comment immediately above yours. You don't need anything from the B2 response to create the download URL.
Yes. i got.. im using native url format which is showing in b2 bucket website. download file using fileId. which is fine to store in DB.
Hey all,
I'm trying to upload a file to b2 and then store that uploaded file's URL in my database so I can refer to it. As the docs said, b2_get_upload_url gives an upload URL that will be used before uploading.
However, when I try to access uploadUrl, I receive:
I also notice that my image in my b2 uses other links such as: https://f002.backblazeb2.com/file/werwerw/thomasRhett.jpg
https://werwerwer.s21.us-west-0222.backblazeb2.com/thomasRhett.jpg
https://f002.backblazeb2.com/b2api/v1/b2_download_file_by_id?fileId=werwerwerwerwerm0050
So how can I actually access my new image's URL?
Thanks! Any help would be appreciated :)