/** * Returns the upload strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobUploadStrategy createUploadStrategy() { BlobUploadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobUploadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobUploadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobUploadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobUploadStrategy(this); } return strategy; }
@Override public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException { FTPClient ftp = createFTP(); try { String path = url.getPath(); String workingDir = path.substring(0, path.lastIndexOf("/")); String filename = message.getMessageId().toString().replaceAll(":", "_"); ftp.setFileType(FTPClient.BINARY_FILE_TYPE); String url; if(!ftp.changeWorkingDirectory(workingDir)) { url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/"; } else { url = this.url.toString(); } if (!ftp.storeFile(filename, in)) { throw new JMSException("FTP store failed: " + ftp.getReplyString()); } return new URL(url + filename); } finally { ftp.quit(); ftp.disconnect(); } }
@Override public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
@Override public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
@Override public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException { FTPClient ftp = createFTP(); try { String path = url.getPath(); String workingDir = path.substring(0, path.lastIndexOf("/")); String filename = message.getMessageId().toString().replaceAll(":", "_"); ftp.setFileType(FTPClient.BINARY_FILE_TYPE); String url; if(!ftp.changeWorkingDirectory(workingDir)) { url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/"; } else { url = this.url.toString(); } if (!ftp.storeFile(filename, in)) { throw new JMSException("FTP store failed: " + ftp.getReplyString()); } return new URL(url + filename); } finally { ftp.quit(); ftp.disconnect(); } }
/** * Returns the upload strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobUploadStrategy createUploadStrategy() { BlobUploadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobUploadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobUploadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobUploadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobUploadStrategy(this); } return strategy; }
@Override public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
@Override public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException { FTPClient ftp = createFTP(); try { String path = url.getPath(); String workingDir = path.substring(0, path.lastIndexOf("/")); String filename = message.getMessageId().toString().replaceAll(":", "_"); ftp.setFileType(FTPClient.BINARY_FILE_TYPE); String url; if(!ftp.changeWorkingDirectory(workingDir)) { url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/"; } else { url = this.url.toString(); } if (!ftp.storeFile(filename, in)) { throw new JMSException("FTP store failed: " + ftp.getReplyString()); } return new URL(url + filename); } finally { ftp.quit(); ftp.disconnect(); } }
/** * Returns the upload strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobUploadStrategy createUploadStrategy() { BlobUploadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobUploadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobUploadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobUploadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobUploadStrategy(this); } return strategy; }
@Override public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
@Override public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException { FTPClient ftp = createFTP(); try { String path = url.getPath(); String workingDir = path.substring(0, path.lastIndexOf("/")); String filename = message.getMessageId().toString().replaceAll(":", "_"); ftp.setFileType(FTPClient.BINARY_FILE_TYPE); String url; if(!ftp.changeWorkingDirectory(workingDir)) { url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/"; } else { url = this.url.toString(); } if (!ftp.storeFile(filename, in)) { throw new JMSException("FTP store failed: " + ftp.getReplyString()); } return new URL(url + filename); } finally { ftp.quit(); ftp.disconnect(); } }
/** * Returns the upload strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobUploadStrategy createUploadStrategy() { BlobUploadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobUploadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobUploadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobUploadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobUploadStrategy(this); } return strategy; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { return uploadStream(message, new FileInputStream(file)); }
public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException { FTPClient ftp = createFTP(); try { String path = url.getPath(); String workingDir = path.substring(0, path.lastIndexOf("/")); String filename = message.getMessageId().toString().replaceAll(":", "_"); ftp.setFileType(FTPClient.BINARY_FILE_TYPE); String url; if(!ftp.changeWorkingDirectory(workingDir)) { url = this.url.toString().replaceFirst(this.url.getPath(), "")+"/"; } else { url = this.url.toString(); } if (!ftp.storeFile(filename, in)) { throw new JMSException("FTP store failed: " + ftp.getReplyString()); } return new URL(url + filename); } finally { ftp.quit(); ftp.disconnect(); } }
/** * Returns the upload strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobUploadStrategy createUploadStrategy() { BlobUploadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobUploadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobUploadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobUploadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobUploadStrategy(this); } return strategy; }