locked
Attachments and file upload/download with node.js backend and mobile service custom API RRS feed

  • Question

  • I have an Azure mobile service that uses a DocumentDB repository via a node.js backend using custom APIs.
    The front end to this is defined in a REST API that I have implemented in a few ways (C#, Swift).

    One thing I cannot get to work is to process in node.js a file upload made via a Http POST request.
    The uploaded file should be added to the specified doc's attachments collection.
    Are there any samples that illustrate how to handle this type of Http POST request in the node.js code?

    I have already used the DocDB .Net bits in a client app to add attachments to a doc directly.
    But now I'd like to do it via a more generic mechanism using Http POST and handling the request in node.

    And once I have the upload working, I will then need to handle the download (made via a Http GET request).

    Any suggestions are most welcome.

    Wednesday, June 24, 2015 8:59 PM

Answers

  • Have you looked through the Node.js SDK unit tests here? https://github.com/Azure/azure-documentdb-node/blob/master/core_sdk/test/test.js. These have some samples of uploading and reading attachments.

    Friday, June 26, 2015 11:27 PM

All replies

  • Have you looked through the Node.js SDK unit tests here? https://github.com/Azure/azure-documentdb-node/blob/master/core_sdk/test/test.js. These have some samples of uploading and reading attachments.

    Friday, June 26, 2015 11:27 PM
  • Hi Aravind,

    Thank you for the pointer to the node.js unit tests.

    But that doesn't really address what I need to do.
    The tests are set up to run in a node.js client against a DocDB repository.

    I need to upload and download attachments using a HTTP request (ie. REST), not via an SDK.
    Then I need to handle the HTTP request in a node.js Custom API in a Azure mobile service that uses DocDB.
    The mobile service code in the API will need to use the SDK.

    Any samples that illustrate this workflow?

    Monday, June 29, 2015 8:47 PM
  • Still looking for a sample that shows a file upload using a REST API call (via .Net POST HttpRequest), not via an SDK.
    And the corresponding node.js server code to process that upload request and store the file in DcoDB.
    Then the download version of this process as well (ie. .Net client to GET the file via HttpRequest and node.js server code to fulfill the GET request).
    Can anyone help?

    Monday, July 13, 2015 8:03 PM