talend

Using tHttpRequest to download an Excel File from Sharepoint with Authentication


I want to download an Excel file from Sharepoint and use it as input for a tFileInputExcel component. tHttpRequest seems to be the only component able to download files from a sharepoint server with authentication.

What of course works is to download the file via tHttpRequest, write the response to a file, and load that file with the tFileInputExcel component.

Example, but I don't want it like that.

Example, but I don't want it like that.

However, I do not want an intermediate file and use the "stream" functionality of the tFileInputExcel component. What I do not achieve is to convert the downloaded content into a stream that is usable by the excel component:

((java.io.InputStream)globalMap.get("what goes here? And where does it come from?"))

Here's an example using the tFileFetch component, but this component is not able to download from sharepoint with authentication.


Solution

  • I extended the tHttpRequest component and created tHttpRequestEx. The new component saves a ByteArrayInputStream to the global map which can be read from the tFileInputExcel component:

    ((java.io.ByteArrayInputStream)globalMap.get("tHttpRequestEx_1_INPUT_STREAM"))
    

    I uploaded the component on exchange.talend.com.

    Of course this has the big disadvantage to use a non-standard component. It may be the better solution to stick with the file download, and use tCreateTemporaryFile to deal with the complexity of creating and deleting a file.