我正在我的应用程序中创建 PDF,并希望将它们上传到 Parse.com。我需要先将 PDF 图像转换为NSData再上传。我知道在 Objective-C 中这是可能的:
NSString *pdfPath = [documentsDirectory stringByAppendingPathComponent:@"test.pdf"];
NSData *myData = [NSData dataWithContentsOfFile:pdfPath];
Run Code Online (Sandbox Code Playgroud)
但是,是否可以在 Swift 中将 PDF 文件转换为 PDF 文件NSData?以下不起作用:
var pdfPath: String = documentsDirectory.stringByAppendingPathComponent("test.pdf")
var myData: NSData = NSData.dataWithContentsOfFile(pdfPath)
Run Code Online (Sandbox Code Playgroud)
相关链接:
我对 Mongo 有问题,我编辑了 (/etc/)mongod.conf和mongodb.conf(bind_ip = 0.0.0.0) 等...但是每次当我尝试使用 mongo shell 时,它都会告诉我“无法连接到 127.0.0.1:27017 ,原因:errno:111连接被拒绝“为什么Mongo连接到127.0.0.1?而且我也不能使用命令-ssl ->Mongo 不知道这个命令行......
谁能帮我 :/ ?
我使用 Linux 服务器 (Ubuntu) MongoDB shell 版本:2.6.12
我尝试安装它来为应用程序创建解析服务器。
我最初犯了一个错误,忘记在用户注册时初始化我的数组字段(设计),因此在我的 Parse 仪表板中,行显示为 ,(undefined)我希望它们是[]。我必须为大约 5000 个用户执行此操作。我尝试了以下代码:
var query = new Parse.Query("User");
query.equalTo("designs", "(undefined)");
query.each(function(obj) {
obj.set("designs", "[]");
return obj.save();
}).then(function() {
// All objects updated.
}, function(err) {
console.log(err);
});
Run Code Online (Sandbox Code Playgroud)
我认为(undefined)应该是其他东西,但我不确定是什么,因为它可能不是字符串。我该如何解决这个问题?
更新:第二次尝试。这是越来越近了吗?
private void updateAllRows(final int skip) {
ParseQuery<ParseUser> query = ParseUser.getQuery();
query.setLimit(500);
query.setSkip(skip);
query.whereDoesNotExist("designs");
query.findInBackground(new FindCallback<ParseUser>() {
@Override
public void done(List<ParseUser> results, ParseException e) {
if (results.size() > 0) {
// The query was successful.
for (int i = 0; i < results.size(); …Run Code Online (Sandbox Code Playgroud) 如何在javascript api中由特定用户调用Parse.Cloud.run ?
服务器代码
Parse.Cloud.define('createChatRoom', async (req, res) => {
if (req.user == null) {
res.error({
message: 'No request user',
});
}
...
}
Run Code Online (Sandbox Code Playgroud) 我有一堆值和PHP数组,我需要将其转换为JSON值,以便通过CURL发布到parse.com
问题是PHP数组被转换为JSON对象(字符串作为键和值,vs字符串作为值)
我结束了
{"showtime":{"Parkne":"1348109940"}}
Run Code Online (Sandbox Code Playgroud)
而不是
{"showtime":{Parkne:"1348109940"}}
Run Code Online (Sandbox Code Playgroud)
并解析抱怨这是一个对象而不是数组,因此不接受它.
如
{"showtime":{"Parkne":"1348109940"}}
Run Code Online (Sandbox Code Playgroud)
是一个JSON对象(key = a string)
无论如何使用json_encode?或一些解决方案?
一切似乎都有效.对Parse.com的请求检查用户是否存在并创建或检索它.我有两个主要问题.首先,当deserializeUser调用该函数时,它返回20个相同的用户,并且该findUser函数应该返回这20个用户.另外,我无法访问req.user
passport.serializeUser(function(user, done) {
done(null, user.objectId);
});
passport.deserializeUser(function(uid, done) {
console.log(uid)
// This outputs the ObjectId 20 TIMES!! ??
Parse.findUser(uid,function(error,user){
done(null, user);
})
});
// CONFIGURATION
app.configure(function() {
app.use(express.bodyParser()); //read
app.use(express.cookieParser()); //read
app.use(express.session({ secret: process.env.SESSION_SECRET || 'abcde' }));
app.use(passport.initialize());
app.use(passport.session());
app.use(app.router);
app.use(express.static(__dirname + '/static'))
});
passport.use(new FacebookStrategy({
clientID: process.env.FACEBOOK_APP_ID || 'app_id',
clientSecret: process.env.FACEBOOK_SECRET || 'fb_secret',
callbackURL: "http://localhost:5000/auth/facebook/callback"
},
function(accessToken, refreshToken, profile, done) {
process.nextTick(function() {
_parse.user(accessToken, profile,function(parseUser){
//this returns the user.....
return done(null, …Run Code Online (Sandbox Code Playgroud) 我一直在使用Parse.com作为我在Android上的照片共享应用程序但是我在列表视图中显示图像和数据时遇到了一些问题.
基本上我想从Parse.com获取数据并将其显示在listView中.
在我的MainActivity中,我有方法downloadContentForMainView() - 我获取数据并将其插入HashMap中 - 在获取所有数据后,我使用适配器在listView中显示数据.
这是我的代码:
private void downloadContentForMainView() throws ParseException
{
ParseQuery query = new ParseQuery("PhotoUpload");
query.whereEqualTo("User", username);
query.findInBackground(new FindCallback() {
public void done(List<ParseObject> content, ParseException pEx) {
// TODO Auto-generated method stub
if(pEx == null && content!=null)
{
if(!(content.isEmpty()))
{
if((content!=null) && (!(content.isEmpty())))
{
for(ParseObject aParseObject : content)
{
ParseFile image = (ParseFile) aParseObject.get("photp");
image.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] imageInBytes, ParseException pEx) {
// TODO Auto-generated method stub
bmp = BitmapFactory.decodeByteArray(imageInBytes, 0, imageInBytes.length);
} …Run Code Online (Sandbox Code Playgroud) 我希望在用户点击链接后显示facebook登录/注册框,但它不起作用.Parse应该使用自己的init函数加载FB SDK,并且应该使用自己的另一个函数显示登录框.我直接从他们的文档中复制并粘贴了代码,因此我认为这不是语法问题.我也尝试在不同的地方初始化Parse SDK,但似乎并不重要.我知道jquery函数正在运行,因为我已经使用警报功能测试它,当我点击目标链接时它会触发,但是登录框不会显示.
我需要修理什么?
>
<body>
<div id="fb-root"></div>
<script>
// Initialize the Parse SDK!
Parse.initialize("***********","***********");
window.fbAsyncInit = function() {
//initialize Facebook SDK via Parse
Parse.FacebookUtils.init({
appId : '***********', // App ID from the App DashboardD
channelUrl : '//http://spilot.koding.com/channel.html', // Channel File for x-domain communication
status : true, // check the login status upon init?
cookie : true, // set sessions cookies to allow your server to access the session?
xfbml : true // parse XFBML tags on this page?
}); …Run Code Online (Sandbox Code Playgroud) 我已将parse方法放在onCreate方法中.但我的问题是如何显示Android Loading ...对话框?
Parse.initialize(this, "a", "b");
ParseQuery query = new ParseQuery("Category");
query.findInBackground(new FindCallback() {
@Override
public void done(List<ParseObject> catObjects, ParseException arg1) {
Log.d("Catlength", String.valueOf(catObjects.size()));
for(int i =0; i<catObjects.size(); i++){
Log.d("lengthName"+String.valueOf(i), String.valueOf(catObjects.get(i).getInt("Id")));
Category category = new Category();
category.Name= catObjects.get(i).getString("CatName");
category.id= catObjects.get(i).getInt("Id");
categories.add(category);
}
if(categories.size()>0){
setListAdapter(new CategoryArrayAdapter(CategoryListActivity.this, R.layout.row_category, categories));
}
else{
Toast.makeText(CategoryListActivity.this, "Our servers are busy. Hit refresh..", 3000).show();
}
}
});
Run Code Online (Sandbox Code Playgroud)
在上面的代码中一切正常,但我无法弄清楚如何显示对话框.
我AsycTask也无法使用,因为解析sdk在后台调用自己的线程,在findInBackground执行完成之前,doInBackground完成Asyc线程.这就是我在主线程中调用它的原因.
结果我总是在我的ArrayList中没有结果.
有人可以赐教.
我正在尝试从Parse下载图像,当我完成从解析程序下载所有图像时我的程序崩溃并出现错误:
NSNull getDataInBackgroundWithBlock:progressBlock:]:发送到实例的无法识别的选择器.
我试过添加一些条件,如
if(![object objectForKey:@"goal_image"]) //If it is nil => exit
Run Code Online (Sandbox Code Playgroud)
但它仍在崩溃.这是我的代码:
PFQuery *query = [PFQuery queryWithClassName:@"Goal"];
[query getObjectInBackgroundWithId:[object objectId] block:^(PFObject *object, NSError *error) {
if(!error)
{
PFFile * imageFile = [object objectForKey:@"goal_image"];
if (imageFile) {
[imageFile getDataInBackgroundWithBlock:^(NSData *data, NSError *error2) {
if (!error2) {
NSString *jpgPath = [NSHomeDirectory() stringByAppendingPathComponent:[NSString stringWithFormat:@"Images/Goals/%@",[object objectId]]];
[data writeToFile:jpgPath atomically:YES];
}
} progressBlock:^(int percentDone) {
if (percentDone == 100) {
NSLog(@"Download Completed");
}
}];
}
}
}];
Run Code Online (Sandbox Code Playgroud) parse-platform ×10
android ×3
java ×2
javascript ×2
objective-c ×2
parse-server ×2
facebook ×1
ios ×1
ios6 ×1
json ×1
linux ×1
listview ×1
mongodb ×1
node.js ×1
passport.js ×1
pfquery ×1
php ×1
swift ×1
ubuntu ×1