Java Code Examples for com.baidu.ueditor.define.AppInfo#IO_ERROR
The following examples show how to use
com.baidu.ueditor.define.AppInfo#IO_ERROR .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Base64Uploader.java From hsweb-framework with Apache License 2.0 | 6 votes |
public static State save(String content, Map<String, Object> conf) { byte[] data = decode(content); long maxSize = (Long) conf.get("maxSize"); if (!validSize(data, maxSize)) { return new BaseState(false, AppInfo.MAX_SIZE); } String suffix = FileType.getSuffix(FileType.JPG); try { FileService fileService = Context.FILE_SERVICE; String path = fileService.saveStaticFile(new ByteArrayInputStream(data), System.currentTimeMillis() + suffix); State state = new BaseState(true); state.putInfo("size", data.length); state.putInfo("title", ""); state.putInfo("url", path); state.putInfo("type", suffix); return state; } catch (Exception e) { log.error("上传base64文件失败",e); } return new BaseState(false, AppInfo.IO_ERROR); }
Example 2
Source File: OSSStorageManager.java From cms with Apache License 2.0 | 6 votes |
public static State saveFileByInputStream(InputStream is, String path, long maxSize) { State state = null; try { if(is.available() > maxSize) { return new BaseState(false, AppInfo.MAX_SIZE); } return saveFileByInputStream(is,path); // OSSUploadUtils.upload(path,is); // state = new BaseState(true); // state.putInfo( "size", is.available() ); // state.putInfo( "title", "" ); // return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 3
Source File: StorageManager.java From sdb-mall with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path, long maxSize) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); if (tmpFile.length() > maxSize) { tmpFile.delete(); return new BaseState(false, AppInfo.MAX_SIZE); } state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 4
Source File: StorageManager.java From sdb-mall with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 5
Source File: StorageManager.java From wangmarket with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path, long maxSize) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); if (tmpFile.length() > maxSize) { tmpFile.delete(); return new BaseState(false, AppInfo.MAX_SIZE); } state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 6
Source File: StorageManager.java From wangmarket with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 7
Source File: StorageManager.java From hsweb-framework with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path, long maxSize) { File tmpFile = getTmpFile(); byte[] dataBuf = new byte[2048]; try (BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE)) { int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); if (tmpFile.length() > maxSize) { tmpFile.delete(); return new BaseState(false, AppInfo.MAX_SIZE); } State state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 8
Source File: StorageManager.java From hsweb-framework with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path) { State state; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[2048]; try (BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE)) { int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { return new BaseState(false, AppInfo.IO_ERROR); } }
Example 9
Source File: StorageManager.java From cms with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path, long maxSize) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); if (tmpFile.length() > maxSize) { tmpFile.delete(); return new BaseState(false, AppInfo.MAX_SIZE); } state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 10
Source File: StorageManager.java From cms with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 11
Source File: OSSStorageManager.java From cms with Apache License 2.0 | 5 votes |
public static State saveBinaryFile(byte[] data, String path) { //File file = new File(path); //State state = valid(file); //if (!state.isSuccess()) { // return state; //} File file =getTmpFile(); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(file)); bos.write(data); bos.flush(); bos.close(); InputStream is = new FileInputStream(file); OSSUploadUtils.upload(path,is); file.delete(); } catch (IOException ioe) { return new BaseState(false, AppInfo.IO_ERROR); } State state = new BaseState(true, path); //State state = new BaseState(true, file.getAbsolutePath()); state.putInfo( "size", data.length ); state.putInfo( "title", file.getName() ); return state; }
Example 12
Source File: StorageManager.java From ueditor with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path, long maxSize) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); if (tmpFile.length() > maxSize) { tmpFile.delete(); return new BaseState(false, AppInfo.MAX_SIZE); } state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }
Example 13
Source File: StorageManager.java From ueditor with Apache License 2.0 | 5 votes |
public static State saveFileByInputStream(InputStream is, String path) { State state = null; File tmpFile = getTmpFile(); byte[] dataBuf = new byte[ 2048 ]; BufferedInputStream bis = new BufferedInputStream(is, StorageManager.BUFFER_SIZE); try { BufferedOutputStream bos = new BufferedOutputStream( new FileOutputStream(tmpFile), StorageManager.BUFFER_SIZE); int count = 0; while ((count = bis.read(dataBuf)) != -1) { bos.write(dataBuf, 0, count); } bos.flush(); bos.close(); state = saveTmpFile(tmpFile, path); if (!state.isSuccess()) { tmpFile.delete(); } return state; } catch (IOException e) { } return new BaseState(false, AppInfo.IO_ERROR); }