Skip to content
This repository was archived by the owner on Sep 6, 2023. It is now read-only.

Testing Uploads

Dwayne Jeng edited this page Sep 19, 2018 · 2 revisions

You can either call Bridge through raw HTTP requests using an HTTP tool such as Postman

Or you can write a script using Java. See UploadTest.java for an example.

Feel free to check out conf/routes in your BridgePF project follow along the code to see how this works internally.

Testing Uploads with HTTP Requests

  1. Create a consented user account as per https://github.com/Sage-Bionetworks/BridgePF/wiki/Creating-Accounts#creating-consented-participants

  2. Find file legacy-survey-encrypted in Integration Tests.

  3. Request an upload session from Bridge.

    POST http://localhost:9000/v3/uploads
    {
      "name":"legacy-survey-encrypted",
      "contentLength":1453,
      "contentType":"application/zip",
      "contentMd5":"c4LAe/36wqQAMXPyKnKm6w=="
    }
    

    This will return an upload ID and an S3 URL. This will also create an entry in the local-(username)-Upload2 table in DynamoDB.

  4. PUT this file (legacy-survey-encrypted) to the S3 URL. Your request needs to include the following headers, all of which need to match the values from the previous step

    • Content-Type
    • Content-MD5
  5. POST http://localhost:9000/v3/uploads/{uploadId}/complete

    This will kick off an asynchronous request to process your upload. You can follow along the logs to see if it's successful, or you can GET http://localhost:9000/v3/uploadstatuses/{uploadId}. This will update the entry in DynamoDB table local-(username)-Upload2 and create a corresponding entry in local-(username)-HealthDataRecord3.

When you've completed these steps, you'll have uploaded some test data to Bridge. Knowing how to do this will be useful for testing upload stuff end to end. If you find yourself uploading a lot of test data (which is likely), feel free to write a script to simplify the process.

To create your own upload, you'll need to know how to zip, encrypt, and find the MD5 hash of your file. This is a little bit trickier to do from the commandline. For a Java example, see ExportTest.java

Upload Documentation