如何在谷歌硬盘中调用实时更新API?

时间:2014-03-23 15:28:44

标签: google-drive-api google-drive-realtime-api

网址:https://developers.google.com/drive/v2/reference/realtime/update

我想将实时文件A复制到REaltime文件B.现在我已成功调用https://developers.google.com/drive/v2/reference/realtime/get从文件A获取JSON数据。

但是我没有调用update来将数据更新到文件B,返回错误:

  

{"错误" {"代码":500,消息":空}}

任何人都可以帮助我吗?这是我的代码:

make_request=function(params, callback) { 
   params['callback'] = function(data){ 
      if (callback != null) { callback(data); }  
   return gapi.client.request(params); 
} 

content=localStorage["realtimeA data"]; 
boundary = "-------314159265358979323846";
delimiter = "\r\n--" + boundary + "\r\n"; close_delim = "\r\n--" + boundary + "--"; base64Data = btoa(content); 
multipartRequestBody = delimiter + "Content-Type: " + "application/json" + "\r\n" + 'Content-Transfer-Encoding: base64\r\n' + "\r\n" + base64Data + close_delim;

params = { 
   path: "/upload/drive/v2/files/0B4ihvYUW4AU1WEQyRTEwaGRNaXM/realtime",
   method: "PUT",        
   params: { uploadType: "media", fileId: "0B4ihvYUW4AU1WEQyRTEwaGRNaXM" }, 
   headers: { "Content-Type": "multipart/mixed; boundary=\"" + boundary + "\"" }, 
   body: multipartRequestBody 
}; 



make_request(params,function callback(data){alert(JSON.stringify(data));} );

1 个答案:

答案 0 :(得分:0)

看起来您正在尝试进行分段上传。支持的options简单或可恢复。您可能想要simple upload(这实际上是您在请求中指定的内容。