See the files.insert example for the basics. In this example, it uses multipart, but the transition to resume is quite simple. Basically, you need to change the uploadType parameter to "renewable". The result from the insert / update will contain a link to the loader, than you can use to send content / check for completion.
media = Google::APIClient::UploadIO.new(file_name, mime_type) result = client.execute( :api_method => drive.files.insert, :body_object => file, :media => media, :parameters => { 'uploadType' => 'resumable', 'alt' => 'json'})
In the upcoming beta version of the client library (any day now :) this will change a bit, so the download will work a little more evenly, regardless of the protocol. In most cases, moving forward, calling execute () will suffice, and it will try to load the file. But the existing method will still work. You can also return by simply calling:
if !result.resumable_upload.complete? client.execute(result.resumable_upload) # Continue sending... end
The example does not display error handling, but can you check result.resumable_upload.complete? or .expired? to check the status. Incomplete renewable downloads expire after a period of inactivity (of the order of an hour or so). If expired, you will need to restart from the beginning.
source share