/** * 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 FileSystemBlobStrategy(final BlobTransferPolicy policy) throws MalformedURLException, URISyntaxException { this.policy = policy; createRootFolder(); }
/** * Returns a {@link FileInputStream} for the give {@link ActiveMQBlobMessage} */ public InputStream getInputStream(ActiveMQBlobMessage message) throws IOException, JMSException { return new FileInputStream(getFile(message)); }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
public void deleteFile(ActiveMQBlobMessage message) throws IOException, JMSException { File f = getFile(message); if (f.exists()) { if (f.delete() == false) throw new IOException("Unable to delete file " + f); } }
/** * Returns the download strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobDownloadStrategy createDownloadStrategy() { BlobDownloadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobDownloadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobDownloadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobDownloadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobDownloadStrategy(this); } return strategy; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
public FileSystemBlobStrategy(final BlobTransferPolicy policy) throws MalformedURLException, URISyntaxException { this.policy = policy; createRootFolder(); }
public URL uploadStream(ActiveMQBlobMessage message, InputStream in) throws JMSException, IOException { File f = getFile(message); try(FileOutputStream out = new FileOutputStream(f)) { byte[] buffer = new byte[policy.getBufferSize()]; for (int c = in.read(buffer); c != -1; c = in.read(buffer)) { out.write(buffer, 0, c); out.flush(); } } // File.toURL() is deprecated return f.toURI().toURL(); }
/** * Returns the download strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobDownloadStrategy createDownloadStrategy() { BlobDownloadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobDownloadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobDownloadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobDownloadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobDownloadStrategy(this); } return strategy; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
public FileSystemBlobStrategy(final BlobTransferPolicy policy) throws MalformedURLException, URISyntaxException { this.policy = policy; createRootFolder(); }
/** * Returns a {@link FileInputStream} for the give {@link ActiveMQBlobMessage} */ public InputStream getInputStream(ActiveMQBlobMessage message) throws IOException, JMSException { return new FileInputStream(getFile(message)); }
/** * 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 FileSystemBlobStrategy(final BlobTransferPolicy policy) throws MalformedURLException, URISyntaxException { this.policy = policy; createRootFolder(); }
/** * Returns a {@link FileInputStream} for the give {@link ActiveMQBlobMessage} */ public InputStream getInputStream(ActiveMQBlobMessage message) throws IOException, JMSException { return new FileInputStream(getFile(message)); }
/** * Returns the download strategy depending on the information from the * uploadURL. Currently supportet HTTP and FTP * * @return */ protected BlobDownloadStrategy createDownloadStrategy() { BlobDownloadStrategy strategy; try { URL url = new URL(getUploadUrl()); if(url.getProtocol().equalsIgnoreCase("FTP")) { strategy = new FTPBlobDownloadStrategy(this); } else if (url.getProtocol().equalsIgnoreCase("FILE")) { strategy = new FileSystemBlobStrategy(this); } else { strategy = new DefaultBlobDownloadStrategy(this); } } catch (MalformedURLException e) { strategy = new DefaultBlobDownloadStrategy(this); } catch (URISyntaxException e) { strategy = new DefaultBlobDownloadStrategy(this); } return strategy; }
public FileSystemBlobStrategy(final BlobTransferPolicy policy) throws MalformedURLException, URISyntaxException { this.policy = policy; createRootFolder(); }