Struct backblaze_b2::raw::upload::UploadAuthorization
[−]
[src]
pub struct UploadAuthorization { pub bucket_id: String, pub upload_url: String, pub authorization_token: String, }
Contains the information needed to authorize an upload to b2. This struct is usually obtained from a B2Authorization using the method get_upload_url.
The b2 website specifies that you may not upload to the same url in parallel.
Fields
bucket_id: String
upload_url: String
Methods
impl UploadAuthorization
[src]
fn auth_header(&self) -> B2AuthHeader
Returns a hyper header that authorizes an upload request.
impl UploadAuthorization
[src]
fn upload_file<InfoType, R: Read, C, S>(
&self,
file: &mut R,
file_name: String,
content_type: Option<Mime>,
content_length: u64,
content_sha1: String,
connector: &C
) -> Result<MoreFileInfo<InfoType>, B2Error> where
InfoType: Deserialize<'de>,
R: Sized,
C: NetworkConnector<Stream = S>,
S: Into<Box<NetworkStream + Send>>,
&self,
file: &mut R,
file_name: String,
content_type: Option<Mime>,
content_length: u64,
content_sha1: String,
connector: &C
) -> Result<MoreFileInfo<InfoType>, B2Error> where
InfoType: Deserialize<'de>,
R: Sized,
C: NetworkConnector<Stream = S>,
S: Into<Box<NetworkStream + Send>>,
Equivalent to calling create_upload_file_request, writing everything in the Read to the Writer and calling finish.
fn create_upload_file_request<C, S>(
&self,
file_name: String,
content_type: Option<Mime>,
content_length: u64,
content_sha1: String,
connector: &C
) -> Result<UploadFileRequest, B2Error> where
C: NetworkConnector<Stream = S>,
S: Into<Box<NetworkStream + Send>>,
&self,
file_name: String,
content_type: Option<Mime>,
content_length: u64,
content_sha1: String,
connector: &C
) -> Result<UploadFileRequest, B2Error> where
C: NetworkConnector<Stream = S>,
S: Into<Box<NetworkStream + Send>>,
Starts a request to upload a file to backblaze b2. This function returns an UploadFileRequest, which implements Write. When writing to this object, the data is sent to backblaze b2. This method of uploading can be used to implement things such as rate limiting of the request.
After the file has been sent, you need to call the finish method on the UploadFileRequest, in order to close the connection.
The upload_file method can be used to upload any Reader easily. The backblaze api
supports not specifying the sha1 checksum. This is not recommended, but if you wish to do
this, simply pass the string do_not_verify
as the sha1 checksum.
The function create_upload_file_request_sha1_at_end might be of interest. This function behaves identically to this function, except the sha1 is passed when calling finish instead of before initiating the request.
Read the backblaze api documentation for more information.
Errors
This function returns a B2Error
in case something goes wrong. Besides the standard
errors, this function can fail with is_invalid_file_name
and is_cap_exceeded
.
fn create_upload_file_request_sha1_at_end<C, S>(
&self,
file_name: String,
content_type: Option<Mime>,
content_length: u64,
connector: &C
) -> Result<UploadFileRequestSha1End, B2Error> where
C: NetworkConnector<Stream = S>,
S: Into<Box<NetworkStream + Send>>,
&self,
file_name: String,
content_type: Option<Mime>,
content_length: u64,
connector: &C
) -> Result<UploadFileRequestSha1End, B2Error> where
C: NetworkConnector<Stream = S>,
S: Into<Box<NetworkStream + Send>>,
Starts a request to upload a file to backblaze b2. This function returns an UploadFileRequestSha1End, which implements Write. When writing to this object, the data is sent to backblaze b2. This method of uploading can be used to implement things such as rate limiting of the request.
The value of the content_length
parameter must be exactly the amount of bytes you are
going to write, not including the 40 byte sha1 appended by the finish method.
After the file has been sent, you need to call the finish method on the UploadFileRequestSha1End, in order to close the connection.
Read the backblaze api documentation for more information.
Errors
This function returns a B2Error
in case something goes wrong. Besides the standard
errors, this function can fail with is_invalid_file_name
and is_cap_exceeded
.
Trait Implementations
impl Clone for UploadAuthorization
[src]
fn clone(&self) -> UploadAuthorization
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more