我目前正在製作一個應用程序,可以從谷歌驅動器上傳和下載文件。 我在使用Drive SDK的android上開發。 問題是,每次我試圖從文件我該怎麼上傳設置修改日期,我總是得到壞請求錯誤400,這是我的喀嚓代碼:錯誤400錯誤的請求上傳使用驅動器API
protected CDriveFile doInBackground(String... file) {
// TODO Auto-generated method stub
com.google.api.services.drive.model.File f=null;
File a=new File(file[1]);
com.google.api.services.drive.model.File body = new com.google.api.services.drive.model.File();
body.setTitle(file[1].substring(file[1].lastIndexOf("/")+1, file[1].length()));
Uri selectedUri = Uri.fromFile(a);
String fileExtension
= MimeTypeMap.getFileExtensionFromUrl(selectedUri.toString());
String mimeType
= MimeTypeMap.getSingleton().getMimeTypeFromExtension(fileExtension);
body.setMimeType(mimeType);
body.setModifiedDate(DateTime.parseRfc3339(file[2]));
//without this, work well.. body.setModifiedDate(DateTime.parseRfc3339(file[2]));
FileContent mediaContent = new FileContent(mimeType, a);
try {
f = service.files().insert(body, mediaContent).execute();
}
文件沒有任何錯誤上傳當我沒有設定修改日期。從我知道我已經提供正確的日期格式爲Google Drive這是RFC3339,糾正我,如果我錯了。 我真的很感激所有你的任何答覆和關注..
有時,400錯誤提供了比只是「錯誤的請求」的更多細節。你有這樣的細節嗎? – Jerome