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

查看:75
本文介绍了使用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中'file'标签的识别。这篇文章/教程证明非常有用,因为它有一个指令,使角度能够识别post标签,以便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天全站免登陆