使用 Javascript SDK 创建 Parse.File [英] Creating a Parse.File with Javascript SDK

查看:25
本文介绍了使用 Javascript SDK 创建 Parse.File的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遵循了法律条文 (Javscript SDK) 以及许多变体,但到目前为止我还无法将图像保存到 Parse.File.我开始认为这是他们在放弃平台之前从未完成的代码?

I've followed the letter of the law (Javscript SDK) along with numerous variations but thus far I have not been able to save an image to a Parse.File. I'm starting think this is code they never finished before they abandoned the platform?

这是我的错误:无法构建文件":需要 2 个参数,但只有 0 个参数.

This is my error: Failed to construct 'File': 2 arguments required, but only 0 present.

这是我的代码:

var base64 = $base64.encode(unescape(encodeURIComponent('a string')));
var file = new Parse.File("logo.png", { base64: base64});
file.save().then(function(){
    var newLogo = new Parse.File();
    newLogo.set('step2.png', file);
    newLogo.save().then(function(){
        offer.set("Alogo.png", newLogo);
        offer.save();
    }).then(function(){}, function(error){console.log(error);});
});

它不会在我的 ParseDB 中保存Alogo.png"或任何处理徽标的图像或注释.您能提供的任何帮助将不胜感激!

It saves no image or note of 'Alogo.png' or anything dealing with a logo in my ParseDB. Any help you could offer would be much appreciated!

推荐答案

有一次,Parse 是正确的.问题不在于我的代码,而在于 Angular,它无法识别 html 中的文件"标签.这个帖子/教程被证明非常有用,因为它有一个指令可以让 angular 识别帖子标签,以便 angular 可以将文件添加到模型中.

For once, Parse was right on point. The issue was not with my code but with Angular and it's lack of recognition of 'file' tags in html. This post/tutorial proved very useful as it has a directive that enables angular to recognize post tags so that angular can add files to the model.

http://uncorkedstudios.com/blog/multipartformdata-file-upload-with-angularjs

这篇关于使用 Javascript SDK 创建 Parse.File的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆