-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get download url #12
Comments
I'm assuming you are wanting the file download URL. You could do this a few of ways. One way is to use the file's ID or combine both the bucket name and the filename. First thing you need to do would be to get the base download URL from the auth command. From the auth response you get the
You should probably cache this somewhere so you don't need to run Then if you know the bucket name and you know the filename you just pull them together like so:
To give you Or if you have the file's ID, which you could get from uploading the file using E.g. from the uploadResponse get the
Pull together a string like this:
Should give you something like: |
Does that answer your question @expertsa ? |
Thank you very much, it's perfectly clear ! |
I'll have a look at how the download URL's work later today and I'll post my
|
@expertsa as far as I can tell, unless you send the mime type as an octet-stream, the browser will try and open it. Here is a great article about the HTML5 That might help you with your problem. |
Hi, thanks, working like a charm with the download attribute. |
@yakovkhalinsky Are you open to the idea of exposing a function for this? Specifically: https://github.com/yakovkhalinsky/backblaze-b2/blob/master/lib/actions/file.js#L261 The example you gave above isn't very complicated, but it'd be far more convenient to write something like: await b2.authorize();
const url = await b2.getFileDownloadUrl(fileId); |
For future reference, the example code for downloading a file by The corrected code looks like: var baseDownloadUrl = authResponse.downloadUrl;
var fileId = uploadResponse.fileId;
var fullDownloadUrl = [
baseDownloadUrl,
'b2api',
'v1',
'b2_download_file_by_id?fileId=' + fileId
].join('/'); |
Is it possible to get file download url or do I have to download on server and handle downloadUrl my self?
The text was updated successfully, but these errors were encountered: