我尝试使用Parse javascript SDK将PDF文件保存为ParseFile:
HTML
var requestUrl = _spPageContextInfo.webAbsoluteUrl + "/_api/lists/getbytitle('" + listTitle + "')/items?$select=Title";
$.getJSON(requestUrl,function(data){
//print results
$.each(data.value,function(i,item){
console.log(item.Title);
});
});
JS
<input type="file" id="profilePhotoFileUpload" onchange="selectFile(event)">
我将字节结果改为:
任何解决方案?
答案 0 :(得分:1)
<强>解决强>
默认文件数据是Text。 我使用FileReader将数据作为base64,然后我保存这样的数据:
fr = new FileReader();
fr.onload = receivedText;
fr.readAsDataURL(file);
function receivedText() {
result = fr.result;
var res = result.split("base64,");
var name = "myFile.pdf";
var parseFile = new Parse.File(name, { base64: res[1] });
parseFile.save().then(function() {
console.log("object saved!");
}, function(error) {
// The file either could not be read, or could not be saved to Parse.
});
}