|
|
@ -176,7 +176,7 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
} |
|
|
|
//3、上传到服务器
|
|
|
|
UploadToOssDTO dto = new UploadToOssDTO(); |
|
|
|
dto.setFileByte(this.fileToByteArray(wxaCodeUnlimit)); |
|
|
|
dto.setFileByte(FileUtils.fileToByteArray(wxaCodeUnlimit)); |
|
|
|
dto.setFileName(wxaCodeUnlimit.getName()); |
|
|
|
Result<String> ossResult = ossFeignClient.uploadFile(dto); |
|
|
|
if (null == ossResult || !ossResult.success() || null == ossResult.getData()) { |
|
|
@ -208,7 +208,7 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
} |
|
|
|
|
|
|
|
UploadToOssDTO dto = new UploadToOssDTO(); |
|
|
|
dto.setFileByte(this.fileToByteArray(wxaCodeUnlimit)); |
|
|
|
dto.setFileByte(FileUtils.fileToByteArray(wxaCodeUnlimit)); |
|
|
|
dto.setFileName(wxaCodeUnlimit.getName()); |
|
|
|
|
|
|
|
Result<String> ossResult = ossFeignClient.uploadFile(dto); |
|
|
@ -218,37 +218,6 @@ public class AppUserServiceImpl implements AppUserService { |
|
|
|
return ossResult; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* File文件转为byte[] |
|
|
|
* |
|
|
|
* @param file |
|
|
|
* @return byte[] |
|
|
|
* @author work@yujt.net.cn |
|
|
|
* @date 2019/9/19 15:56 |
|
|
|
*/ |
|
|
|
private byte[] fileToByteArray(File file) { |
|
|
|
try { |
|
|
|
//获取输入流
|
|
|
|
FileInputStream fis = new FileInputStream(file); |
|
|
|
//新的 byte 数组输出流,缓冲区容量1024byte
|
|
|
|
ByteArrayOutputStream bos = new ByteArrayOutputStream(1024); |
|
|
|
//缓存
|
|
|
|
byte[] b = new byte[1024]; |
|
|
|
int n; |
|
|
|
while ((n = fis.read(b)) != NumConstant.ONE_NEG) { |
|
|
|
bos.write(b, NumConstant.ZERO, n); |
|
|
|
} |
|
|
|
fis.close(); |
|
|
|
//改变为byte[]
|
|
|
|
byte[] data = bos.toByteArray(); |
|
|
|
bos.close(); |
|
|
|
return data; |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 根据openId登录 |
|
|
|
* |
|
|
|