MediaFileUpload
in package
Manage large file uploads, which may be media but can be any type of sizable data.
Table of Contents
Constants
- UPLOAD_MEDIA_TYPE = 'media'
- UPLOAD_MULTIPART_TYPE = 'multipart'
- UPLOAD_RESUMABLE_TYPE = 'resumable'
Properties
- $boundary : string
- $chunkSize : int
- $client : Client
- $data : string
- $httpResultCode : int
- Result code from last HTTP call
- $mimeType : string
- $progress : int
- $request : RequestInterface
- $resumable : bool
- $resumeUri : string
- $size : int
Methods
- __construct() : mixed
- getHttpResultCode() : int
- Return the HTTP result code from the last call made.
- getProgress() : int
- Return the progress on the upload
- getRequest() : mixed
- getResumeUri() : mixed
- getUploadType() : string
- Valid upload types: - resumable (UPLOAD_RESUMABLE_TYPE) - media (UPLOAD_MEDIA_TYPE) - multipart (UPLOAD_MULTIPART_TYPE)
- nextChunk() : mixed
- Send the next part of the file to upload.
- resume() : mixed
- Resume a previously unfinished upload
- setChunkSize() : mixed
- setFileSize() : mixed
- Set the size of the file that is being uploaded.
- fetchResumeUri() : mixed
- makePutRequest() : false|mixed
- Sends a PUT-Request to google drive and parses the response, setting the appropiate variables from the response()
- process() : RequestInterface
- transformToUploadUrl() : mixed
Constants
UPLOAD_MEDIA_TYPE
public
mixed
UPLOAD_MEDIA_TYPE
= 'media'
UPLOAD_MULTIPART_TYPE
public
mixed
UPLOAD_MULTIPART_TYPE
= 'multipart'
UPLOAD_RESUMABLE_TYPE
public
mixed
UPLOAD_RESUMABLE_TYPE
= 'resumable'
Properties
$boundary
private
string
$boundary
$chunkSize
private
int
$chunkSize
$client
private
Client
$client
$data
private
string
$data
$httpResultCode
Result code from last HTTP call
private
int
$httpResultCode
$mimeType
private
string
$mimeType
$progress
private
int
$progress
$request
private
RequestInterface
$request
$resumable
private
bool
$resumable
$resumeUri
private
string
$resumeUri
$size
private
int
$size
Methods
__construct()
public
__construct(Client $client, RequestInterface $request, string $mimeType, string $data[, bool $resumable = false ][, bool $chunkSize = false ]) : mixed
Parameters
- $client : Client
- $request : RequestInterface
- $mimeType : string
- $data : string
-
The bytes you want to upload.
- $resumable : bool = false
- $chunkSize : bool = false
-
File will be uploaded in chunks of this many bytes. only used if resumable=True
getHttpResultCode()
Return the HTTP result code from the last call made.
public
getHttpResultCode() : int
Return values
int —code
getProgress()
Return the progress on the upload
public
getProgress() : int
Return values
int —progress in bytes uploaded.
getRequest()
public
getRequest() : mixed
getResumeUri()
public
getResumeUri() : mixed
getUploadType()
Valid upload types: - resumable (UPLOAD_RESUMABLE_TYPE) - media (UPLOAD_MEDIA_TYPE) - multipart (UPLOAD_MULTIPART_TYPE)
public
getUploadType(mixed $meta) : string
Parameters
- $meta : mixed
Tags
Return values
stringnextChunk()
Send the next part of the file to upload.
public
nextChunk([string|bool $chunk = false ]) : mixed
Parameters
- $chunk : string|bool = false
-
Optional. The next set of bytes to send. If false will use $data passed at construct time.
resume()
Resume a previously unfinished upload
public
resume(mixed $resumeUri) : mixed
Parameters
- $resumeUri : mixed
-
the resume-URI of the unfinished, resumable upload.
setChunkSize()
public
setChunkSize(mixed $chunkSize) : mixed
Parameters
- $chunkSize : mixed
setFileSize()
Set the size of the file that is being uploaded.
public
setFileSize(mixed $size) : mixed
Parameters
- $size : mixed
-
- int file size in bytes
fetchResumeUri()
private
fetchResumeUri() : mixed
makePutRequest()
Sends a PUT-Request to google drive and parses the response, setting the appropiate variables from the response()
private
makePutRequest(RequestInterface $request) : false|mixed
Parameters
- $request : RequestInterface
-
the Request which will be send
Return values
false|mixed —false when the upload is unfinished or the decoded http response
process()
private
process() : RequestInterface
Tags
Return values
RequestInterfacetransformToUploadUrl()
private
transformToUploadUrl() : mixed