我尝试如下.
但该文件将转到根目录(My-Drive).
但该文件将转到根目录(My-Drive).
var Metadata = { 'title': fileData.fileName,'mimeType': contentType,'parents':["0B6NmmF3ovpsbExuOEc1R2JzSFEp"] // It is one of my folder's id. }; var base64Data = btoa(reader.result); var multipartRequestBody = delimiter + 'Content-Type: application/json\r\n\r\n' + JSON.stringify(Metadata) + delimiter + 'Content-Type: ' + contentType + '\r\n' + 'Content-Transfer-Encoding: base64\r\n' + '\r\n' + base64Data + close_delim; var request = gapi.client.request({ 'path': '/upload/drive/v2/files','method': 'POST','params': {'uploadType': 'multipart'},'headers': { 'Content-Type': 'multipart/mixed; boundary="' + boundary + '"' },'body': multipartRequestBody}); request.execute(callback);