我有解开按钮,我想在硬按上打开详细信息页面。
所以我怎么可能告诉我。
答案 0 :(得分:3)
insertFile: function (filename, content, callback) {
const boundary = '-------314159265358979323846';
const delimiter = "\r\n--" + boundary + "\r\n";
const close_delim = "\r\n--" + boundary + "--";
{
var contentType = 'application/vnd.google-apps.document';
var metadata = {
'title': filename,
'mimeType': 'text/html',
'description': 'Created'
};
// TODO: replace this with a library - https://github.com/beatgammit/base64-js/blob/master/lib/b64.js
var base64Data = window.btoa(unescape(encodeURIComponent(content)));
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', 'convert': true },
'headers': {
'Content-Type': 'multipart/mixed; boundary="' + boundary + '"'
},
'body': multipartRequestBody
});
if (!callback) {
callback = function (file) {
console.log(file)
};
}
request.execute(callback);
}
}