blackbaze https://www.backblaze.com/docs/cloud-storage-api-operations **Note** : sharable link not available without adding credit card ### for downloading Blackblaze B2 operates with a different API than AWS S3, but downloading a file using a read access token is straightforward. To access files in a B2 bucket, you'll typically follow these steps for authorization and then proceed with downloading the desired file. Steps to Download a File from Backblaze B2 Get Authorization Token: You'll need to authenticate against the B2 API to obtain an authorization token. This is generally done via an API call using your account's Application Key ID and Application Key. Make a Download Request: Use the authorization token to make a request to download the file from the bucket. Here are detailed steps: Step 1: Get Authorization Token Use the following endpoint to get your authorization token: Request: ```bash curl -X GET "https://api.backblazeb2.com/b2_authorize_account" \ -H "Authorization: Basic $(echo -n 'APPLICATION_KEY_ID:APPLICATION_KEY' | base64)" ``` Replace `APPLICATION_KEY_ID` and `APPLICATION_KEY` with your actual credentials. Response: This will return a JSON object containing your apiUrl, authorizationToken, and other details: ```json { "accountId": "some_account_id", "bucketId": "some_bucket_id", "bucketName": "your_bucket", "downloadUrl": "https://f002.backblazeb2.com", "authorizationToken": "your_authorization_token", ... } ``` Step 2: Download the File Once you have the downloadUrl and authorizationToken, you can download files stored in your B2 bucket. You'll need to format the URL correctly based on the file's path in the bucket. Example cURL Command to Download File: Assuming your download URL is https://f002.backblazeb2.com and you have the bucket name and file name: `curl -L -o LOCAL_FILENAME "https://f002.backblazeb2.com/file/Bucket_Name/Path/To/Your/File.txt" \ -H "Authorization: your_authorization_token"` Example of the Full Process Here’s a combined example of both steps in shell commands: ```bash # Step 1: Get Authorization Token auth_response=$(curl -s -X GET "https://api.backblazeb2.com/b2_authorize_account" \ -H "Authorization: Basic $(echo -n 'APPLICATION_KEY_ID:APPLICATION_KEY' | base64)") # Extract the necessary fields using jq (install it if you don't have it) apiUrl=$(echo $auth_response | jq -r '.apiUrl') downloadUrl=$(echo $auth_response | jq -r '.downloadUrl') authToken=$(echo $auth_response | jq -r '.authorizationToken') # Step 2: Download the file curl -L -o LOCAL_FILENAME "${downloadUrl}/file/YOUR_BUCKET_NAME/PATH/TO/YOUR/FILE.txt" \ -H "Authorization: ${authToken}" ``` Important Notes Authorization: Make sure to replace APPLICATION_KEY_ID, APPLICATION_KEY, Your_Bucket_Name, and PATH/TO/YOUR/FILE.txt with your actual values. Token Validity: The authorization token will expire after a limited time, so you may need to call the authorization endpoint to get a new token if it has expired. Using Environment Variables: For security, consider storing sensitive credentials in environment variables instead of hardcoding them directly into your scripts. With these steps, you should be able to easily download files from Backblaze B2 using your read access token!