Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 311 and 402] [Versions 311 and 403]

Copyright 2012 Google Inc. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

File Size: 341 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

Google_Http_MediaFileUpload:: (13 methods):
  __construct()
  setFileSize()
  getProgress()
  getHttpResultCode()
  makePutRequest()
  nextChunk()
  resume()
  process()
  transformToUploadUrl()
  getUploadType()
  getResumeUri()
  fetchResumeUri()
  setChunkSize()


Class: Google_Http_MediaFileUpload  - X-Ref

Manage large file uploads, which may be media but can be any type
of sizable data.

__construct(Google_Client $client,Google_Http_Request $request,$mimeType,$data,$resumable = false,$chunkSize = false,$boundary = false)   X-Ref

param: $mimeType string
param: $data string The bytes you want to upload.
param: $resumable bool
param: bool $chunkSize File will be uploaded in chunks of this many bytes.

setFileSize($size)   X-Ref
Set the size of the file that is being uploaded.

param: $size - int file size in bytes

getProgress()   X-Ref
Return the progress on the upload

return: int progress in bytes uploaded.

getHttpResultCode()   X-Ref
Return the HTTP result code from the last call made.

return: int code

makePutRequest(Google_Http_Request $httpRequest)   X-Ref
Sends a PUT-Request to google drive and parses the response,
setting the appropiate variables from the response()

param: Google_Http_Request $httpRequest the Reuqest which will be send
return: false|mixed false when the upload is unfinished or the decoded http response

nextChunk($chunk = false)   X-Ref
Send the next part of the file to upload.

param: [$chunk] the next set of bytes to send. If false will used $data passed

resume($resumeUri)   X-Ref
Resume a previously unfinished upload

param: $resumeUri the resume-URI of the unfinished, resumable upload.

process()   X-Ref

return: array|bool

transformToUploadUrl()   X-Ref
No description

getUploadType($meta)   X-Ref
Valid upload types:
- resumable (UPLOAD_RESUMABLE_TYPE)
- media (UPLOAD_MEDIA_TYPE)
- multipart (UPLOAD_MULTIPART_TYPE)

param: $meta
return: string

getResumeUri()   X-Ref
No description

fetchResumeUri()   X-Ref
No description

setChunkSize($chunkSize)   X-Ref
No description