我正在尝试在解析时上传视频文件。要上传视频,我使用以下代码:
File inputFile = new File(uri.toString());
FileInputStream fis = new FileInputStream(inputFile);
ByteArrayOutputStream bos= new ByteArrayOutputStream();
byte[] buf = new byte[(int)inputFile.length()];
for (int readNum; (readNum=fis.read(buf)) != -1;){
bos.write(buf,0,readNum);
}
byte[] bytes = bos.toByteArray();
ParseFile file = new ParseFile("testVideo1.mp4", bytes);
ParseObject parseObject = new ParseObject("chat1");
parseObject.saveInBackground();
但inputfile
File
对象未转换为FileInputStream
。
答案 0 :(得分:0)
感谢您的帮助,这帮助我开始上传视频进行解析,我发现了您的问题,只是没有将解析文件放入parseobject中。基本上,您从未发送过视频
File inputFile = new File(uri.toString());
FileInputStream fis = new FileInputStream(inputFile);
ByteArrayOutputStream bos= new ByteArrayOutputStream();
byte[] buf = new byte[(int)inputFile.length()];
for (int readNum; (readNum=fis.read(buf)) != -1;){
bos.write(buf,0,readNum);
}
byte[] bytes = bos.toByteArray();
ParseFile file = new ParseFile("testVideo1.mp4", bytes);
ParseObject parseObject = new ParseObject("chat1");
//addition
parseObject.put("video",file);
//it should work with this
parseObject.saveInBackground();