I’m currently making an app that can upload and download file from Google Drive.
i’m developing on android using Drive SDK.
The problem is everytime i try to set modified date from file i gonna upload, i always get bad request error 400. this is my snip code:
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();
}
file uploaded without any error when i’m not set the modified date. from what i know i already supply the correct date format for Google Drive which is RFC3339, correct me if i wrong.
i really appreciate any answer and attention from all of you..
In the Drive API reference, we have this description about modifiedDate :
So I suppose you cant directly set modified date on insertion