目录

MediaHttpUploader

Class Info

public final class MediaHttpUploader

MediaHttpUploader class.

Public Constructor Summary

Constructor Name

MediaHttpUploader(AbstractInputStreamContent mediaContent, HttpTransport transport, HttpRequestInitializer httpRequestInitializer)

Constructs a MediaHttpUploader object.

Public Method Summary

Qualifier and Type

Method Name and Description

double

getProgress()

Obtains the upload progress indicating the percentage of bytes that have been uploaded. The value ranges from 0.0 (0%) to 1.0 (100%).

MediaHttpUploaderProgressListener

getProgressListener()

Obtains the progress listener.

long

getTotalTimeRequired()

Obtains the total upload time.

UploadState

getUploadState()

Obtains the current upload status of the uploader.

MediaHttpUploader

setDirectUploadEnabled(boolean directUploadEnabled)

Sets whether to enable direct upload.

MediaHttpUploader

setProgressListener(MediaHttpUploaderProgressListener progressListener)

Sets the progress listener to send progress notifications.

Public Constructors

[h2]MediaHttpUploader

Constructor

public MediaHttpUploader(AbstractInputStreamContent mediaContent, HttpTransport transport, HttpRequestInitializer httpRequestInitializer)

Constructs a MediaHttpUploader object.

Parameters

Name

Description

mediaContent

Input stream content of the media to be uploaded.

transport

HttpTransport to use for requests.

httpRequestInitializer

Initializer to use when creating an HTTP request, which can be null.

Public Methods

[h2]setDirectUploadEnabled

Method

public MediaHttpUploader setDirectUploadEnabled(boolean directUploadEnabled)

Sets whether to enable direct upload.

Parameters

Name

Description

directUploadEnabled

Indicates whether to enable direct upload.

true: Yes. The entire media data will be uploaded in a single request.

false: No. The media data will be uploaded in data chunks using the protocol of resumable media upload.

Returns

Type

Description

MediaHttpUploader

A MediaHttpUploader object.

[h2]setProgressListener

Method

public MediaHttpUploader setProgressListener(MediaHttpUploaderProgressListener progressListener)

Sets the progress listener to send progress notifications.

Parameters

Name

Description

progressListener

Progress listener.

Returns

Type

Description

MediaHttpUploader

A MediaHttpUploader object.

[h2]getProgressListener

Method

public MediaHttpUploaderProgressListener getProgressListener()

Obtains the progress listener.

Returns

Type

Description

MediaHttpUploaderProgressListener

A MediaHttpUploaderProgressListener object.

[h2]getProgress

Method

double getProgress()

Obtains the upload progress indicating the percentage of bytes that have been uploaded. The value ranges from 0.0 (0%) to 1.0 (100%).

Returns

Type

Description

double

Upload progress. The value ranges from 0.0 (0%) to 1.0 (100%).

Throws

Name

Description

java.io.IOException

I/O exception thrown upon an API call failure. You can use the getMessage() method to obtain the error description.

[h2]getTotalTimeRequired

Method

long getTotalTimeRequired()

Obtains the total upload time.

Returns

Type

Description

long

Total upload time.

[h2]getUploadState

Method

UploadState getUploadState()

Obtains the current upload status of the uploader.

Returns

Type

Description

UploadState

An UploadState object.