quickblox web 如何上传个人资料图片 [英] quickblox web how to upload profile picture
问题描述
我正在尝试从 javascript 文档上传个人资料图片 (blob_id),但找不到方法,我不知道是否应该使用此代码段,甚至不知道如何使用它:(
I'm trying to upload a profile picture (blob_id) from a javascript document and I can't find a way, I don´t know if I should use this snippets or even how to use it :(
如果你能帮我,我会很感激
I'll be so thankfull if you could help me
谢谢
QB.users.update({ id: user_creds.user_id, website: "http://quickblox.com"}, function(error, response){
if(error) {
console.log(error);
} else {
// Success
}
});
推荐答案
很抱歉.我们很快就会完善文档.
sorry about this. We'll be beefing up the documentation soon.
上传个人资料图片的方法
Here's how to upload a profile picture
我们将有一个文件输入:
We'll have a file input:
<input type="file" id="picture" />
然后假设您的环境中有 jQuery,我们将像这样引用它:
Then assuming you have jQuery in your environment, we'll reference it like this:
var profile_picture = $("#picture")[0].files;
然后您像这样将文件上传到 Quickblox AWS:
Then you upload the file to Quickblox AWS like so:
QB.content.createAndUpload({file: profile_picture, public: true}, function(error, response) {
if (error) {
console.log("upload didn't work");
} else {
var blob_id = response.id;
}
});
如您所见,blob 的 ID 是响应的 id
字段.
As you can see, the ID of the blob is the id
field of the response.
然后在创建新用户时将此 blob ID 添加为新用户的 blob_id
字段:
You then add this blob ID as the blob_id
field of a new user when you create him/her:
QB.users.create({login: "username_here", password: "password_here", blob_id: blob_id_here}, function(error, response){
if(error) {
console.log(error);
} else {
}
});
我制作了一个页面来演示 Javascript SDK 的上传功能 - 您可以在这里查看:http://www.quickblox.com/alex/websdk/upload.html
I made a page which demos the uploading functionality of the Javascript SDK - you can check it out here: http://www.quickblox.com/alex/websdk/upload.html
这篇关于quickblox web 如何上传个人资料图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!