Saving and retreving photos and videos in Parse (Android)

前端 未结 1 1214
无人共我
无人共我 2021-01-12 14:55

I was looking at the Parse Android docs and saw that to save photos and videos, you have to initialize a new ParseFile with a name and a byte[] of data and save

相关标签:
1条回答
  • 2021-01-12 15:43

    From Uri to get byte[] I do the following things,

     ByteArrayOutputStream baos = new ByteArrayOutputStream();
    FileInputStream fis = new FileInputStream(new File(yourUri));
    
    byte[] buf = new byte[1024];
    int n;
    while (-1 != (n = fis.read(buf)))
        baos.write(buf, 0, n);
    
    byte[] videoBytes = baos.toByteArray(); //this is the video in bytes.
    
    0 讨论(0)
提交回复
热议问题