我要上传的解析云服务器中的图像机器人。但我不能这样做。
我曾尝试以下code:
可绘制绘制= getResources()getDrawable(R.drawable.profilepic)。
点阵位图=(位图)(位图)绘制()
ByteArrayOutputStream流=新ByteArrayOutputStream();
bitmap.com preSS(Bitmap.Com pressFormat.PNG,100,流);
byte []的数据= stream.toByteArray();
ParseFile镜像文件=新ParseFile(image.png,数据);
imageFile.saveInBackground();
请让我知道我该怎么做。
我添加了一个赏金找到最权威code针对这个常见问题
解决方案保存的parseObject背景
//的parseObject
的parseObject pObject =新的parseObject(ExampleObject);
pObject.put(为mynumber,号码);
pObject.put(MyString的,名);
pObject.saveInBackground(); //异步,没有回调
保存在回调的背景
pObject.saveInBackground(新SaveCallback(){
@覆盖
公共无效完成(ParseException的前){
如果(前== NULL){
isSaved = TRUE;
} 其他 {
//失败
isSaved = FALSE;
}
}
});
保存...()方法的变化包括以下内容:
saveAllinBackground()可以节省的parseObject带或不带一个回调。
白水回收(名单<的parseObject>对象)保存ParseObjects的列表。
saveAllinBackground(名单<的parseObject>对象)保存在ParseObjects名单
背景。
saveEventually()可以让您的数据对象保存到服务器在将来的某个时候;使用
该方法适用于解析云计算目前无法使用。
在一个的parseObject已成功保存在云中,它被分配一个唯一的对象ID。此Object-ID是非常重要的,因为它唯一标识的parseObject实例。则可以使用对象ID,例如,以确定是否该对象被成功地保存在云,用于检索和刷新定解析对象实例,和用于删除一个特定的parseObject
我希望你能解决你的问题。
I want to upload an image in parse cloud server in android. But I am unable to do so.
I have tried the following code:
Drawable drawable = getResources().getDrawable(R.drawable.profilepic) ;
Bitmap bitmap = (Bitmap)(Bitmap)drawable()
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] data = stream.toByteArray();
ParseFile imageFile = new ParseFile("image.png", data);
imageFile.saveInBackground();
Please let me know how can I do it.
I've added a bounty to find the best definitive code for this common problem
解决方案Save ParseObject in the background
// ParseObject
ParseObject pObject = new ParseObject("ExampleObject");
pObject.put("myNumber", number);
pObject.put("myString", name);
pObject.saveInBackground(); // asynchronous, no callback
Save in the background with callback
pObject.saveInBackground(new SaveCallback () {
@Override
public void done(ParseException ex) {
if (ex == null) {
isSaved = true;
} else {
// Failed
isSaved = false;
}
}
});
Variations of the save...() method include the following:
saveAllinBackground() saves a ParseObject with or without a callback.
saveAll(List<ParseObject> objects) saves a list of ParseObjects.
saveAllinBackground(List<ParseObject> objects) saves a list of ParseObjects in the
background.
saveEventually() lets you save a data object to the server at some point in the future; use
this method if the Parse cloud is not currently accessible.
Once a ParseObject has been successfully saved on the Cloud, it is assigned a unique Object-ID. This Object-ID is very important as it uniquely identifies that ParseObject instance. You would use the Object-ID, for example, to determine if the object was successfully saved on the cloud, for retrieving and refreshing a given Parse object instance, and for deleting a particular ParseObject.
I hope you will solve your problem..