List of usage examples for com.google.api.client.googleapis.media MediaHttpUploader DEFAULT_CHUNK_SIZE
int DEFAULT_CHUNK_SIZE
To view the source code for com.google.api.client.googleapis.media MediaHttpUploader DEFAULT_CHUNK_SIZE.
Click Source Link
From source file:org.mrpdaemon.android.encdroid.GoogleDriveOutputStream.java
License:Open Source License
public GoogleDriveOutputStream(final GoogleDriveFileProvider fileProvider, final String dstPath, final long length) throws IOException { this.failed = false; Log.d(TAG, "Creating output stream for path " + dstPath); // Create pipes pipeDrive = new PipedInputStream(); pipeToWrite = new PipedOutputStream(pipeDrive); // Delete file touched by encfs-java if (fileProvider.exists(dstPath)) { fileProvider.delete(dstPath);//from w w w . ja v a 2 s . c o m } final File newFile = fileProvider.prepareFileForCreation(dstPath); thread = new Thread(new Runnable() { @Override public void run() { try { InputStreamContent streamContent = new InputStreamContent("application/octet-stream", pipeDrive); streamContent.setLength(length); Drive.Files.Insert insert = fileProvider.getDriveService().files().insert(newFile, streamContent); // Use resumable upload to not time out for larger files MediaHttpUploader uploader = insert.getMediaHttpUploader(); uploader.setDirectUploadEnabled(false); uploader.setChunkSize(MediaHttpUploader.DEFAULT_CHUNK_SIZE); insert.execute(); } catch (IOException e) { if (e.getMessage() != null) { GoogleDriveOutputStream.this.fail(e.getMessage()); } else { GoogleDriveOutputStream.this.fail(e.toString()); } } } }); thread.start(); }