| | |
| | | import com.java110.core.smo.file.IFileInnerServiceSMO; |
| | | import com.java110.dto.file.FileDto; |
| | | import com.java110.core.client.FtpUploadTemplate; |
| | | import com.java110.utils.util.Base64Convert; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import sun.misc.BASE64Encoder; |
| | | |
| | | import java.io.File; |
| | | import java.io.FileOutputStream; |
| | | import java.io.OutputStream; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.UUID; |
| | | |
| | | @RestController |
| | | public class FileInnerServiceSMOImpl extends BaseServiceSMO implements IFileInnerServiceSMO { |
| | |
| | | byte[] fileImg = ftpUploadTemplate.downFileByte(ftpPath, fileName, java110Properties.getFtpServer(), |
| | | java110Properties.getFtpPort(), java110Properties.getFtpUserName(), |
| | | java110Properties.getFtpUserPassword()); |
| | | |
| | | String context = new BASE64Encoder().encode(fileImg); |
| | | try { |
| | | File file = new File("/home/hc/img/"+ UUID.randomUUID().toString()+".jpg"); |
| | | if(!file.exists()){ |
| | | file.createNewFile(); |
| | | } |
| | | OutputStream out = new FileOutputStream(file); |
| | | out.write(fileImg); |
| | | }catch (Exception e){ |
| | | e.printStackTrace(); |
| | | } |
| | | //String context = new BASE64Encoder().encode(fileImg); |
| | | String context = Base64Convert.byteToBase64(fileImg); |
| | | |
| | | fileDto.setContext(context); |
| | | fileDtos.add(fileDto); |