Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

storing multiple ParseFile objects in single ParseObject

ANDROID

This is how I store ParseFile List into 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();

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

This is how i retrieve it and get the first image from the list

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);
    }

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.

I observed that in ParseFile, data and url is null.

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

like image 262
Timmy Simons Avatar asked Jul 13 '13 20:07

Timmy Simons


1 Answers

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

like image 89
Héctor Ramos Avatar answered Sep 19 '22 15:09

Héctor Ramos