Android base64 上传图片
16lz
2021-01-23
public static String encodeBase64File(String path) throws Exception {
File file = new File(path);
FileInputStream inputFile = new FileInputStream(file);
byte[] buffer = new byte[(int)file.length()];
inputFile.read(buffer);
inputFile.close();
return Base64.encodeToString(buffer, Base64.DEFAULT);
File file = new File(path);
FileInputStream inputFile = new FileInputStream(file);
byte[] buffer = new byte[(int)file.length()];
inputFile.read(buffer);
inputFile.close();
return Base64.encodeToString(buffer, Base64.DEFAULT);
}
//特别注意这里要把参数URLEncoder.encode 这个问题害我不浅
params.put("photos", URLEncoder.encode(base64Code, "UTF-8"));
更多相关文章
- ui布局参数设置
- android线性布局参数详解
- android_relative布局参数学习
- Android 模拟器创建参数说明
- 参数设置
- android图片压缩质量参数Bitmap.Config RGB_565等的含义