Advertisement
Guest User

Untitled

a guest
Jan 4th, 2015
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. public SomeObjectThatContainsFileForExamplePipedInputStream callSomeMethodAndRecieveDownloadedFileInSomeForm(final String name) throws IOException {
  2.         //here any instance of OutputStream - it needs to be passed to client.getFile lower (for now it is PipedOutputStream)
  3.         PipedInputStream inputStream = new PipedInputStream(); // for now
  4.         PipedOutputStream outputStream = new PipedOutputStream(inputStream);
  5.  
  6.  
  7.         //some dropbox client object
  8.         DbxClient client = new DbxClient();
  9.         try {
  10.             //important part - Dropbox API downloads the file from Dropbox servers to the outputstream object passed as the third parameter
  11.             client.getFile("/" + name, null, outputStream);
  12.         } catch (DbxException e){
  13.             e.printStackTrace();
  14.         } finally {
  15.             outputStream.close();
  16.         }
  17.         return inputStream;
  18.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement