function addFileToFolder(arrayBuffer, i) {
var index = i;
var fileName = files[index].name;
const boundary = '-------314159265358979323846';
const delimiter = "\r\n--" + boundary + "\r\n";
const close_delim = "\r\n--" + boundary + "--";
var fileContnet="this is the simple text file"
const contentType = 'application/json';
const contentTypeImage = 'application/octet-stream';
var metadata = {
'name': fileName,
'mimeType': contentTypeImage
};
var multipartRequestBody =
delimiter +
'Content-Type:application/json \r\n\r\n' +
JSON.stringify(metadata) +
delimiter +
'Content-Type: ' + contentTypeImage + '\r\n\r\n' +
files[index] +
close_delim;
// var fileCollectionEndpoint ="https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart";
var len=(arrayBuffer.byteLength);
alert(len);
var request = gapi.client.request({
'path': '/upload/drive/v3/files',
'method': 'POST',
'params': {'uploadType': 'multipart'},
'headers': {
'Content-Type': 'multipart/related; boundary="' + boundary + '"',
'Content-Length':len
},
'body': multipartRequestBody});
request.execute(function(data){console.log(data)});
//----------------------
}
}
答案 0 :(得分:0)
FixNum与nil 错误
在你的情况下,total_skus可能是零。因此,使用to_i
将nil转换为整数@ order.products.count< @ order.try(:total_skus).to_i