Welcome to the new Box Support website. Check out all the details here on what’s changed.

Box java sdk - download converted file

Answered
New post

Comments

3 comments

  • carycheng77

    Hey ,

     

    Apologies for the late reply! The good new is that there is a convenient way to achieve this via the Box API without downloading to local server and converting and re-uploading.

     

    Once a file is uploaded to Box you can fetch different representations of the file you uploaded. You can absolutely retrieve a PDF representation of the file you uploaded. The flow would go roughly as follows:

     

    1. Upload your file to Box
    2. Make a call to the /representations endpoint with the pdf file type in the x-reps-hint header field.
    3. Get back the pdf representation of your file uploaded.

    For step by step on how to do this please refer to our API Reference for Get Representations

     

    This functionality is also implemented in the Box Java SDK. For code example please refer to docs here.

    Please note that this is a two part process. Sometimes representations are not available immediately after a file is uploaded. If you are running your script at a later time after you upload then this should not be a problem. However, if you are running your script directly after uploading then you will need to call the `getInfoWithRepresentations(...)` method and check the status for pdf representation, then call `getRepresentationContent(...)` to return an output stream of your pdf file.

     

    If you have any issues please do not hesitate to reach out!

    0
    Comment actions Permalink
  • srip
    Thanks, carycheng77.
     
     
    Certainly a much better option than the way I was trying to implement. Will look into it.
     

     

    0
    Comment actions Permalink
  • Box Product Support

    Hey, is there representation related feature also in box-android-sdk ?

    I have been looking for some example like this:

    https://github.com/box/box-java-sdk/blob/master/doc/files.md#get-file-representations

    But for android one:

    https://github.com/box/box-android-sdk/blob/master/doc/Files.md

     

    I tried to compose getting representations by myself, but representations are always null. So I am looking for some proven sample.

     

    My current approach is to get com.box.androidsdk.content.models.Boxfile and check it's representations -> this is unfortunatelly always null. If there would be required representation, I would pass it as parameter to another call com.box.androidsdk.content.BoxApiFile.getDownloadRepresentationRequest and hopefully get proper file in required representation.

     

    Could you point me to some working sample? Or have you any idea, how to get proper representation object for file saved in box?

    0
    Comment actions Permalink

Please sign in to leave a comment.