217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
# File 'lib/backup/storage/dropbox.rb', line 217
def upload(chunk_size = 1024**2 * 4)
while @offset < @total_size
@file_obj.seek(@offset) unless @file_obj.pos == @offset
data = @file_obj.read(chunk_size)
begin
resp = @client.parse_response(
@client.partial_chunked_upload(data, @upload_id, @offset)
)
rescue DropboxError => err
resp = JSON.parse(err.http_response.body) rescue {}
raise err unless resp['offset']
end
@offset = resp['offset']
@upload_id ||= resp['upload_id']
end
end
|