Android 将文件数据发布到服务器?
如何将这种格式的数据发送到服务器Android 将文件数据发布到服务器?,android,image,http,postman,posting,Android,Image,Http,Postman,Posting,如何将这种格式的数据发送到服务器 只需将其编码为Base64即可 试试这个 private static String encodeFileToBase64Binary(File file) { String encodedfile = null; try { FileInputStream fileInputStreamReader = new FileInputStream(file); byte[] bytes = new byte[
只需将其编码为Base64即可 试试这个
private static String encodeFileToBase64Binary(File file) {
String encodedfile = null;
try {
FileInputStream fileInputStreamReader = new FileInputStream(file);
byte[] bytes = new byte[(int) file.length()];
fileInputStreamReader.read(bytes);
encodedfile = Base64.encodeToString(bytes, 1);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return encodedfile;
}