我上传了一个pdf文件进行解析,它在数据浏览器中可见,但是当我尝试查看它时,说无法加载。我相信我的上传代码是正确的,因为它适用于.docx文件,但不适用于.pdf。有任何想法吗?这是我的代码
function uploadFile (uploadId,fileName){
var fileUploadControl = $("#fileUpload")[0];
if(fileUploadControl.files.length>0){
var file = fileUploadControl.files[0];
var parseFile = new Parse.File(fileName,file);
parseFile.save().then(function(){
console.log("nsucciess");
//file has been saved to parse
},function(error){
//file could not be read or saved
console.log("error");
});
//var currentUser = Parse.User.current();
//currentUser.set(fileName,parseFile);
var ProjectFile = Parse.Object.extend("ProjectFile");
var projectFile = new ProjectFile();
projectFile.set("file",parseFile);
projectFile.save(null,{
success:function(projectFile){
console.log("success");
}
});
alert("everything works");
}
else{
alert("oh no");
}
}
答案 0 :(得分:2)
刚刚解决:您必须在Parse.com提供的链接之前添加https://docs.google.com/viewer?url=
。例如:
var yourUploadedPdfLink = "http://files.parsetfss.com/56accfec-1956-xxxxxx-abe8-xxxxxx/tfss-a7076e9c-xxxx-45fe-a8e8-xxxxxxx-MYDOCUMENT.pdf"
要阅读它:"https://docs.google.com/viewer?url=" + yourUploadedPdfLink
它会起作用。因此,您无法从Parse.com仪表板上阅读pdf文件(目前)。