public CTFFile uploadLargeFile(File src) throws RemoteException { String fieldId = this.getSimpleFileStorageAppSoap().startFileUpload(getSessionId()); byte[] buffer = new byte[UPLOAD_FILE_CHUNK_SIZE]; try { InputStream fileInputStream = new FileDataSource(src).getInputStream(); while (true) { int count = fileInputStream.read(buffer); if (count == -1) { break; } this.getSimpleFileStorageAppSoap().write(getSessionId(), fieldId, getFirstNBytesOfBuffer(buffer, count)); } this.getSimpleFileStorageAppSoap().endFileUpload(getSessionId(), fieldId); fileInputStream.close(); } catch (IOException e) { throw new Error(e); } return new CTFFile(this, fieldId); }
InputStream is = fileDataSource.getInputStream(); byte[] document = Io.getBytesFromInputStream(is); swa.addAttachment(document, mime_type, id);