Backblaze-B2V4

 view release on metacpan or  search on metacpan

README.md  view on Meta::CPAN

        print $b2->latest_error();
        # if none, will be 'No error message found'

# DESCRIPTION / SET UP

This module should help you create buckets and store/retrieve files in the
Backblaze B2 cloud storage service using V4 of their API.

Backblaze makes it easy to sign up for B2 from here:

        https://www.backblaze.com/b2/sign-up.html

Then enable the B2 service as per these instructions:

        https://www.backblaze.com/b2/docs/quick_account.html

Next, visit the 'App Keys' section of the 'My Account' area, and look for
the 'Add a New Application Key' button to create an application key.  You
will need a key with Read and Write access.  Be sure to note the Application Key
ID  as well as the Application Key itself. They do not show you that Application
Key again, so copy it immediately.

Please store the Application Key pair in a secure way, preferably encrypted
when not in use by your software.

## b2\_client Command Line Utility

Backblaze::B2V4 includes the 'b2\_client' command line utility to
easily download or upload files from B2.  Please execute 'b2\_client help'
for more details, and here are a few examples:

        # download a file to current directory
        b2_client get MyPictures FamilyPhoto.jpg
        
        # download a file to a target directory
        b2_client get MyPictures FamilyPhoto.jpg /home/ginger/photos
        
        # upload a file to B2
        b2_client put MyPictures /home/ginger/photos/AnotherFamilyPhoto.jpg

There is also an official command line utility from Backblaze that does a
whole lot more: 

        https://www.backblaze.com/b2/docs/quick_command_line.html

## BackBlaze B2 also has a S3-compatible API

Backblaze has added an S3-compatible API, which you can read about here:

        https://www.backblaze.com/b2/docs/s3_compatible_api.html

They are continuing to support their native B2 API, so I will continue
to use and support this module.  I have not tested the S3 modules with
Backblaze, but if you already have an S3 integration, it is worth
checking out how Paws::S3 or Awes::S3 works with Backblaze.

## Testing Your Credentials

During install, this module will attempt to connect to B2 and download
a 16KB file into memory. To test using your B2 account
credentials, set these environmental varables prior to attempting
to install:

        B2_APP_KEY_ID - The application key ID for the key you wish to test.
        B2_APP_KEY - The application key -- is never displayed in the B2 UI.
        B2_ACCT_ID - Your account ID; will be the ID of your master key
        B2_TEST_FILE_ID: The long (75+ char) GUID for your target file.

The GUID for a file is displayed when you click on that file's name
in the 'Browse Files' section of the B2 UI.

# METHODS

## new

Creates the B2 client object and initiates an API session with B2.

Requires two arguments: 
	application\_key => the Application Key from Backblaze,
	application\_key\_id => the Application Key ID from Backblze,

Returns your B2 client object.

## b2\_download\_file\_by\_id

Retrieves a file plus metadata given the GUID of that file.  
The 'file\_id' argument is required and will be the file's GUID.  
If you would like to auto-save the file, provide a path to an 
existing directory via the 'save\_to\_location' argument.

On success, will return the $response hashref with these keys:

        file_contents
        content-length
        content-type
        x-bz-file-id
        x-bz-file-name
        x-bz-content-sha1

See https://www.backblaze.com/b2/docs/b2\_download\_file\_by\_id.html

## b2\_download\_file\_by\_name

Works like b2\_download\_file\_by\_id() except that it expects 'bucket\_name'
and 'file\_name' named arguments arguments.  
If you would like to auto-save the file, provide a path to an 
existing directory via the 'save\_to\_location' argument.

See https://www.backblaze.com/b2/docs/b2\_download\_file\_by\_name.html

## b2\_upload\_file

Uploads a new file into B2. Accepts these named arguments:

        bucket_name => required, name of destination bucket,
        content_type => optional mime type; defaults to b2/x-auto,
        file_location => optional, full path of file to upload incl name
        new_file_name => optional, filename for file on B2
        file_contents => optional scalar with file contents

If you do not provide 'file\_location', then you need to provide



( run in 1.431 second using v1.01-cache-2.11-cpan-140bd7fdf52 )