GData.UploadStream¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
class |
|
|
|
|
|
|
|
|
|
|
|
Virtual Methods¶
- Inherited:
Properties¶
Name |
Type |
Flags |
Short Description |
---|---|---|---|
r/w/co |
The authorization domain for the upload. |
||
r/w/co |
An optional cancellable used to cancel the entire upload operation. |
||
r/w/co |
The content length (in bytes) of the file being uploaded. |
||
r/w/co |
The content type of the file being uploaded. |
||
r/w/co |
The entry used for metadata to upload. |
||
r/w/co |
The HTTP request method to use when uploading the file. |
||
r/w/co |
The service which is used to authorize the upload. |
||
r/w/co |
The slug of the file being uploaded. |
||
r/w/co |
The URI to upload the data and metadata to. |
Signals¶
- Inherited:
Fields¶
- Inherited:
Name |
Type |
Access |
Description |
---|---|---|---|
parent |
r |
Class Details¶
- class GData.UploadStream(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
All the fields in the
GData.UploadStream
structure are private and should never be accessed directly.New in version 0.5.0.
- classmethod new(service, domain, method, upload_uri, entry, slug, content_type, cancellable)¶
- Parameters:
service (
GData.Service
) – aGData.Service
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
to authorize the upload, orNone
method (
str
) – the HTTP method to useupload_uri (
str
) – the URI to upload, which must be HTTPSentry (
GData.Entry
orNone
) – the entry to upload as metadata, orNone
slug (
str
) – the file’s slug (filename)content_type (
str
) – the content type of the file being uploadedcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
for the entire upload stream, orNone
- Returns:
a new
Gio.OutputStream
, orNone
; unref withGObject.Object.unref
()- Return type:
Creates a new
GData.UploadStream
, allowing a file to be uploaded from aGLib.Data
service using standardGio.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
Gio.OutputStream
API on aGData.UploadStream
can also return any relevant specific error fromGData.ServiceError
, orGData.ServiceError.PROTOCOL_ERROR
in the general case.If a
Gio.Cancellable
is provided in cancellable, the upload operation may be cancelled at any time from another thread usingGio.Cancellable.cancel
(). In this case, any ongoing network activity will be stopped, and any pending or future calls toGio.OutputStream
API on theGData.UploadStream
will returnGio.IOErrorEnum.CANCELLED
. Note that theGio.Cancellable
objects which can be passed to individualGio.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
Gio.OutputStream.write
() on theGData.UploadStream
.New in version 0.9.0.
- classmethod new_resumable(service, domain, method, upload_uri, entry, slug, content_type, content_length, cancellable)¶
- Parameters:
service (
GData.Service
) – aGData.Service
domain (
GData.AuthorizationDomain
orNone
) – theGData.AuthorizationDomain
to authorize the upload, orNone
method (
str
) – the HTTP method to useupload_uri (
str
) – the URI to uploadentry (
GData.Entry
orNone
) – the entry to upload as metadata, orNone
slug (
str
) – the file’s slug (filename)content_type (
str
) – the content type of the file being uploadedcontent_length (
int
) – the size (in bytes) of the file being uploadedcancellable (
Gio.Cancellable
orNone
) – aGio.Cancellable
for the entire upload stream, orNone
- Returns:
a new
Gio.OutputStream
, orNone
; unref withGObject.Object.unref
()- Return type:
Creates a new resumable
GData.UploadStream
, allowing a file to be uploaded from aGLib.Data
service using standardGio.OutputStream
API. The upload will useGLib.Data
's resumable upload API, so should be more reliable than a normal upload (especially if the file is large). See theGData documentation on resumable uploads for more information.
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, content_type and content_length 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. content_length must be the size of the file being uploaded (not including the XML for any associated
GData.Entry
) in bytes. Zero is accepted if a metadata-only upload is being performed.As well as the standard GIO errors, calls to the
Gio.OutputStream
API on aGData.UploadStream
can also return any relevant specific error fromGData.ServiceError
, orGData.ServiceError.PROTOCOL_ERROR
in the general case.If a
Gio.Cancellable
is provided in cancellable, the upload operation may be cancelled at any time from another thread usingGio.Cancellable.cancel
(). In this case, any ongoing network activity will be stopped, and any pending or future calls toGio.OutputStream
API on theGData.UploadStream
will returnGio.IOErrorEnum.CANCELLED
. Note that theGio.Cancellable
objects which can be passed to individualGio.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
Gio.OutputStream.write
() on theGData.UploadStream
.New in version 0.13.0.
- get_authorization_domain()¶
- Returns:
the
GData.AuthorizationDomain
used to authorize the upload, orNone
- Return type:
Gets the authorization domain used to authorize the upload, as passed to
GData.UploadStream.new
(). It may beNone
if authorization is not needed for the upload.New in version 0.9.0.
- get_cancellable()¶
- Returns:
the
Gio.Cancellable
for the entire upload operation- Return type:
Gets the
Gio.Cancellable
for the entire upload operation,GData.UploadStream
:cancellable
.New in version 0.8.0.
- get_content_length()¶
- Returns:
the size of the file being uploaded
- Return type:
Gets the size (in bytes) of the file being uploaded. This will be -1 for a non-resumable upload, and zero or greater for a resumable upload.
New in version 0.13.0.
- get_content_type()¶
- Returns:
the content type of the file being uploaded
- Return type:
Gets the content type of the file being uploaded.
New in version 0.5.0.
- get_entry()¶
- Returns:
the entry used for metadata, or
None
- Return type:
Gets the entry being used to upload metadata, if one was passed to
GData.UploadStream.new
().New in version 0.5.0.
- get_method()¶
- Returns:
the HTTP request method in use
- Return type:
Gets the HTTP request method being used to upload the file, as passed to
GData.UploadStream.new
().New in version 0.7.0.
- get_response()¶
- Returns:
the server’s response to the upload, or
None
- length:
return location for the length of the response, or
None
- Return type:
Returns the server’s response to the upload operation performed by the
GData.UploadStream
. If the operation is still underway, or the server’s response hasn’t been received yet,None
is returned and length is set to -1.If there was an error during the upload operation (but it is complete),
None
is returned, and length is set to 0.While it is safe to call this function from any thread at any time during the network operation, the only way to guarantee that the response has been set before calling this function is to have closed the
GData.UploadStream
by callingGio.OutputStream.close
() on it, without cancelling the close operation. Once the stream has been closed, all network communication is guaranteed to have finished. Note that if a call toGio.OutputStream.close
() is cancelled,Gio.OutputStream.is_closed
() will immediately start to returnTrue
, even if theGData.UploadStream
is still attempting to flush the network buffers asynchronously — consequently,GData.UploadStream.get_response
() may still returnNone
and a length of-1. The only reliable way to determine if the stream has been fully closed in this situation is to check the results of
GData.UploadStream.get_response
(), rather thanGio.OutputStream.is_closed
().New in version 0.5.0.
- get_service()¶
- Returns:
the
GData.Service
used to authorize the upload- Return type:
Gets the service used to authorize the upload, as passed to
GData.UploadStream.new
().New in version 0.5.0.
- get_slug()¶
- Returns:
the slug of the file being uploaded
- Return type:
Gets the slug (filename) of the file being uploaded.
New in version 0.5.0.
- get_upload_uri()¶
- Returns:
the URI which the file is being uploaded to
- Return type:
Gets the URI the file is being uploaded to, as passed to
GData.UploadStream.new
().New in version 0.5.0.
Property Details¶
- GData.UploadStream.props.authorization_domain¶
- Name:
authorization-domain
- Type:
- Default Value:
- Flags:
The authorization domain for the upload, against which the
GData.Service
:authorizer
for theGData.DownloadStream
:service
should be authorized. This may beNone
if authorization is not needed for the upload.New in version 0.9.0.
- GData.UploadStream.props.cancellable¶
- Name:
cancellable
- Type:
- Default Value:
- Flags:
An optional cancellable used to cancel the entire upload operation. If a
Gio.Cancellable
instance isn’t provided for this property at construction time (i.e. toGData.UploadStream.new
()), one will be created internally and can be retrieved usingGData.UploadStream.get_cancellable
() and used to cancel the upload operation withGio.Cancellable.cancel
() just as if it was passed toGData.UploadStream.new
().If the upload operation is cancelled using this
Gio.Cancellable
, any ongoing network activity will be stopped, and any pending or future calls toGio.OutputStream
API on theGData.UploadStream
will returnGio.IOErrorEnum.CANCELLED
. Note that theGio.Cancellable
objects which can be passed to individualGio.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 usingGData.UploadStream
:cancellable
.New in version 0.8.0.
- GData.UploadStream.props.content_length¶
- Name:
content-length
- Type:
- Default Value:
-1
- Flags:
The content length (in bytes) of the file being uploaded (i.e. as returned by
Gio.FileInfo.get_size
()). Note that this does not include the length of the XML serialisation ofGData.UploadStream
:entry
, if set.If this is -1 the upload will be non-resumable; if it is non-negative, the upload will be resumable.
New in version 0.13.0.
- GData.UploadStream.props.content_type¶
- Name:
content-type
- Type:
- Default Value:
- Flags:
The content type of the file being uploaded (i.e. as returned by
Gio.FileInfo.get_content_type
()).New in version 0.5.0.
- GData.UploadStream.props.entry¶
- Name:
entry
- Type:
- Default Value:
- Flags:
The entry used for metadata to upload.
New in version 0.5.0.
- GData.UploadStream.props.method¶
- Name:
method
- Type:
- Default Value:
- Flags:
The HTTP request method to use when uploading the file.
New in version 0.7.0.
- GData.UploadStream.props.service¶
- Name:
service
- Type:
- Default Value:
- Flags:
The service which is used to authorize the upload, and to which the upload relates.
New in version 0.5.0.
- GData.UploadStream.props.slug¶
- Name:
slug
- Type:
- Default Value:
- Flags:
The slug of the file being uploaded. This is usually the display name of the file (i.e. as returned by
Gio.FileInfo.get_display_name
()).New in version 0.5.0.