Creates a new UploadStream, allowing a file to be uploaded from a GData service using standard OutputStream API.
The HTTP method to use should be specified in method
, and will typically be either SOUP_METHOD_POST
(for
insertions) or SOUP_METHOD_PUT
(for updates), according to the server and the upload_uri
.
If entry
is specified, it will be attached to the upload as the entry to which the file being uploaded belongs. Otherwise,
just the file written to the stream will be uploaded, and given a default entry as determined by the server.
slug
and content_type
must be specified before the upload begins, as they describe the file being streamed.
slug
is the filename given to the file, which will typically be stored on the server and made available when downloading the
file again. content_type
must be the correct content type for the file, and should be in the service's list of acceptable
content types.
As well as the standard GIO errors, calls to the OutputStream API on a UploadStream can also return any relevant specific error from ServiceError, or PROTOCOL_ERROR in the general case.
If a Cancellable is provided in cancellable
, the upload operation may be cancelled at any time
from another thread using cancel. In this case, any ongoing network activity will be stopped, and any pending
or future calls to OutputStream API on the
UploadStream will return CANCELLED. Note that the Cancellable objects
which can be passed to individual OutputStream operations will not cancel the upload operation proper
if cancelled — they will merely cancel that API call. The only way to cancel the upload operation completely is using this
cancellable
.
Note that network communication won't begin until the first call to write on the UploadStream.
service |
a Service |
domain |
the AuthorizationDomain to authorize the upload, or |
method |
the HTTP method to use |
upload_uri |
the URI to upload, which must be HTTPS |
entry |
the entry to upload as metadata, or |
slug |
the file's slug (filename) |
content_type |
the content type of the file being uploaded |
cancellable |
a Cancellable for the entire upload stream, or |
a new OutputStream, or |