我有下面的代碼,應該從我的Android設備上傳圖片到我的谷歌驅動器。如何更快地上傳到GoogleDrive?
private void saveFileToDrive() {
progressDialog = ProgressDialog.show(this, "", "Loading...");
Thread t = new Thread(new Runnable() {
@Override
public void run() {
try {
// File's binary content
java.io.File fileContent = new java.io.File(fileUri.getPath());
FileContent mediaContent = new FileContent("image/jpeg", fileContent);
// File's metadata.
File body = new File();
body.setTitle(fileContent.getName());
body.setMimeType("image/jpeg");
File file = service.files().insert(body, mediaContent).execute();
if (file != null) {
showToast("Photo uploaded: " + file.getTitle());
progressDialog.dismiss();
//startCameraIntent();
}
} catch (UserRecoverableAuthIOException e) {
startActivityForResult(e.getIntent(), REQUEST_AUTHORIZATION);
} catch (IOException e) {
e.printStackTrace();
}
}
});
t.start();
}
東西是上傳需要太長時間。這很奇怪,因爲圖像不是太大
我想如果我通過原始的Drive App上傳它,它會做得更快。
1)有沒有辦法讓上傳速度更快,同時又不損害圖像質量?
2)我以爲使用回調,但什麼是新的線程和回調的最佳做法?
3)我該怎麼讓上傳當前數字uplaod進度(X%,到目前爲止已完成)
有沒有使用任何準備的簽名\模式?
什麼是您的POST URL? – Pete
你的意思是什麼變量? –