List of usage examples for org.apache.commons.net.ftp FTPSClient storeFileStream
public OutputStream storeFileStream(String remote) throws IOException
From source file:org.mule.transport.ftps.FtpsConnector.java
/** * Well get the output stream (if any) for this type of transport. Typically this * will be called only when Streaming is being used on an outbound endpoint * * @param endpoint the endpoint that releates to this Dispatcher * @param event the current event being processed * @return the output stream to use for this request or null if the transport * does not support streaming/*from ww w.j av a2s .c om*/ */ @Override public OutputStream getOutputStream(OutboundEndpoint endpoint, MuleEvent event) throws MuleException { try { final EndpointURI uri = endpoint.getEndpointURI(); String filename = getFilename(endpoint, event.getMessage()); final FTPSClient client; try { client = this.createFTPSClient(endpoint); } catch (Exception e) { throw new ConnectException(e, this); } try { OutputStream out = client.storeFileStream(filename); if (out == null) { throw new IOException("FTP operation failed: " + client.getReplyString()); } return new CallbackOutputStream(out, new CallbackOutputStream.Callback() { public void onClose() throws Exception { try { if (!client.completePendingCommand()) { client.logout(); client.disconnect(); throw new IOException("FTP Stream failed to complete pending request"); } } finally { releaseFtp(uri, client); } } }); } catch (Exception e) { logger.debug("Error getting output stream: ", e); releaseFtp(uri, client); throw e; } } catch (ConnectException ce) { // Don't wrap a ConnectException, otherwise the retry policy will not go into effect. throw ce; } catch (Exception e) { throw new DispatchException(CoreMessages.streamingFailedNoStream(), event, endpoint, e); } }