问题
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
Thanks
QB.users.update({ id: user_creds.user_id, website: "http://quickblox.com"}, function(error, response){
if(error) {
console.log(error);
} else {
// Success
}
});
回答1:
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" />
Then assuming you have jQuery in your environment, we'll reference it like this:
var profile_picture = $("#picture")[0].files;
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;
}
});
As you can see, the ID of the blob is the id
field of the response.
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 {
}
});
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
来源:https://stackoverflow.com/questions/23676110/quickblox-web-how-to-upload-profile-picture