/** * 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 uploadStream(ActiveMQBlobMessage message, InputStream fis) throws JMSException, IOException { URL url = createMessageURL(message); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("PUT"); connection.setDoOutput(true); // use chunked mode or otherwise URLConnection loads everything into // memory // (chunked mode not supported before JRE 1.5) connection.setChunkedStreamingMode(transferPolicy.getBufferSize()); try(OutputStream os = connection.getOutputStream()) { byte[] buf = new byte[transferPolicy.getBufferSize()]; for (int c = fis.read(buf); c != -1; c = fis.read(buf)) { os.write(buf, 0, c); os.flush(); } } catch (IOException error) { throw new IOException("PUT failed to: " + url, error); } if (!isSuccessfulCode(connection.getResponseCode())) { throw new IOException("PUT to " + url + " was not successful: " + connection.getResponseCode() + " " + connection.getResponseMessage()); } return url; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
public URL uploadStream(ActiveMQBlobMessage message, InputStream fis) throws JMSException, IOException { URL url = createMessageURL(message); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("PUT"); connection.setDoOutput(true); // use chunked mode or otherwise URLConnection loads everything into // memory // (chunked mode not supported before JRE 1.5) connection.setChunkedStreamingMode(transferPolicy.getBufferSize()); try(OutputStream os = connection.getOutputStream()) { byte[] buf = new byte[transferPolicy.getBufferSize()]; for (int c = fis.read(buf); c != -1; c = fis.read(buf)) { os.write(buf, 0, c); os.flush(); } } catch (IOException error) { throw new IOException("PUT failed to: " + url, error); } if (!isSuccessfulCode(connection.getResponseCode())) { throw new IOException("PUT to " + url + " was not successful: " + connection.getResponseCode() + " " + connection.getResponseMessage()); } return url; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
/** * 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 uploadStream(ActiveMQBlobMessage message, InputStream fis) throws JMSException, IOException { URL url = createMessageURL(message); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("PUT"); connection.setDoOutput(true); // use chunked mode or otherwise URLConnection loads everything into // memory // (chunked mode not supported before JRE 1.5) connection.setChunkedStreamingMode(transferPolicy.getBufferSize()); OutputStream os = connection.getOutputStream(); byte[] buf = new byte[transferPolicy.getBufferSize()]; for (int c = fis.read(buf); c != -1; c = fis.read(buf)) { os.write(buf, 0, c); os.flush(); } os.close(); fis.close(); if (!isSuccessfulCode(connection.getResponseCode())) { throw new IOException("PUT was not successful: " + connection.getResponseCode() + " " + connection.getResponseMessage()); } return url; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
/** * 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 uploadStream(ActiveMQBlobMessage message, InputStream fis) throws JMSException, IOException { URL url = createMessageURL(message); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("PUT"); connection.setDoOutput(true); // use chunked mode or otherwise URLConnection loads everything into // memory // (chunked mode not supported before JRE 1.5) connection.setChunkedStreamingMode(transferPolicy.getBufferSize()); try(OutputStream os = connection.getOutputStream()) { byte[] buf = new byte[transferPolicy.getBufferSize()]; for (int c = fis.read(buf); c != -1; c = fis.read(buf)) { os.write(buf, 0, c); os.flush(); } } catch (IOException error) { throw new IOException("PUT failed to: " + url, error); } if (!isSuccessfulCode(connection.getResponseCode())) { throw new IOException("PUT to " + url + " was not successful: " + connection.getResponseCode() + " " + connection.getResponseMessage()); } return url; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { try(FileInputStream fis = new FileInputStream(file)) { return uploadStream(message, fis); } }
/** * 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 uploadStream(ActiveMQBlobMessage message, InputStream fis) throws JMSException, IOException { URL url = createMessageURL(message); HttpURLConnection connection = (HttpURLConnection)url.openConnection(); connection.setRequestMethod("PUT"); connection.setDoOutput(true); // use chunked mode or otherwise URLConnection loads everything into // memory // (chunked mode not supported before JRE 1.5) connection.setChunkedStreamingMode(transferPolicy.getBufferSize()); try(OutputStream os = connection.getOutputStream()) { byte[] buf = new byte[transferPolicy.getBufferSize()]; for (int c = fis.read(buf); c != -1; c = fis.read(buf)) { os.write(buf, 0, c); os.flush(); } } catch (IOException error) { throw new IOException("PUT failed to: " + url, error); } if (!isSuccessfulCode(connection.getResponseCode())) { throw new IOException("PUT to " + url + " was not successful: " + connection.getResponseCode() + " " + connection.getResponseMessage()); } return url; }
public URL uploadFile(ActiveMQBlobMessage message, File file) throws JMSException, IOException { return uploadStream(message, new FileInputStream(file)); }
/** * 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; }