class Barite::B2File

Overview

Represents a file in a specific bucket on Backblaze. This is normally generated by calling B2#file. Once you have this object you can upload and download the file using B2File#upload, B2File#download.

Defined in:

barite.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(b2 : Barite::B2, bucket_name : String, file_name : String) #

Create a reference for the named file in the named bucket. Note that the @max_versions parameter is not yet used. Every time you upload the same file name you will create a new version of the same file. Note that B2 filenames are strings but they can include a path, such as "abc/def". Some tools will interpret this as a file called 'def' in a folder 'abc', and it is OK to think of it like this, but the 'abc/' is really just part of the filename.


[View source]

Instance Method Detail

def b2 : Barite::B2 #

The linked B2 object.


[View source]
def bucket_id : String #

Retrieve the bucket ID. Caches the result on first use.


[View source]
def bucket_name : String #

The bucket containing this file.


[View source]
def download(local_file_path : String) #

Downloads the referenced file to a local file. local_file_path is the pull path, including filename. If the stored file has a modification time stored in a "X-Bz-Info-src_last_modified_millis" header, the timestamp will be set on the file after a successful download.


[View source]
def file_name : String #

The filename as stored in the bucket.


[View source]
def upload(local_file_path : String) #

Upload the file from the local file path. The modification time from the local file is set in the "X-Bz-Info-src_last_modified_millis" header, so it will be returned when the file is downloaded.


[View source]
def upload_token : String #

Retrieve the upload token for the bucket. Caches the result on first use. Upload tokens seem to be re-usable, so you only need to get it once.


[View source]
def upload_url : String #

Retrieve the upload URL. Caches the result on first use.


[View source]