在单个 ParseObject 中存储多个 ParseFile 对象 [英] storing multiple ParseFile objects in single ParseObject

查看:22
本文介绍了在单个 ParseObject 中存储多个 ParseFile 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我将 ParseFile 列表存储到 ParseObject 的方式

ParseObject pObject = new ParseObject();    
ArrayList<ParseFile> pFileList = new ArrayList<ParseFile>();
    for (String thumbPath : thumbList) {
       byte[] imgData = convertFileToByteArray(thumbPath);
       ParseFile pFile = new ParseFile("mediaFiles",imgData);
       pFileList.add(pFile);    
    }

       pObject.addAll("mediaFiles", pFileList); 
       pObject.saveEventually();

在此调用之后,它不会在数据浏览器中显示插入的行,尽管它在表中显示行数为 1

after this call it does not show the inserted row in data browser, although it shows rowcount of 1 in table

这就是我检索它并从列表中获取第一张图像的方式

List<ParseFile> pFileList = (ArrayList<ParseFile>) pObject.get("mediaFiles");
    if (!pFileList.isEmpty()) {
          ParseFile pFile = pFileList.get(0);
          byte[] bitmapdata = pFile.getData();  // here it throws error
          bitmap = BitmapFactory.decodeByteArray(bitmapdata, 0, bitmapdata.length);
    }

我能够检索所有 String 列,但是对于mediaFiles"列,在执行 getData() 时我得到了这个异常.com.parse.ParseException:目标主机不得为空,或在参数中设置.

I am able to retrieve all String columns , but for "mediaFiles" column while doing getData() I get thisexception. com.parse.ParseException: Target host must not be null, or set in parameters.

我观察到在 ParseFile 中,数据和 url 为空.

谁能告诉我如何将多个 ParseFile 对象存储和检索到单个 ParseObject 中的代码?

Can somebody please show me the code on how to store and retrieve multiple ParseFile objects into single ParseObject?

推荐答案

在将 ParseFiles 与 Parse 对象关联之前,尝试使用 save 方法上传它们.

Try uploading the ParseFiles using the save method before associating them with the Parse Object.

这篇关于在单个 ParseObject 中存储多个 ParseFile 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆