-
Notifications
You must be signed in to change notification settings - Fork 22
Testing Uploads
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.
This doc will also contain code links if you want to follow along in the code to see how this works internally.
-
If needed, create a consented user account as per https://github.com/Sage-Bionetworks/BridgeServer2/wiki/Creating-Accounts#creating-consented-participants
-
Find file legacy-survey-encrypted in Integration Tests.
-
Request an upload session from Bridge. Entry Point
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.
-
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
-
POST http://localhost:9000/v3/uploads/{uploadId}/complete
Entry PointThis 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
-
If needed, create a consented user account as per https://github.com/Sage-Bionetworks/BridgeServer2/wiki/Creating-Accounts#creating-consented-participants
-
Submit Health Data to Bridge Entry Point
POST http://localhost:9000/v3/healthdata { "appVersion":"version 1.0.0, build 2", "createdOn":"2018-08-25T15:34:13.084+0900", "phoneInfo":"MacBook Air (11-inch, Early 2015); OS X 10.10.5", "schemaId":"legacy-survey", "schemaRevision":1, "data":{ "AAA":["Yes"], "BBB":["fencing", "running", 3] } }
This will synchronously process the submitted health data and return the processed health data, with the record ID, status, and parsed fields (if any). The health data record will also be persisted in DynamoDB as an entry in local-(username)-HealthDataRecord3.
For more information about Bridge, see: https://sagebase.org/bridge/. For information about developing on Bridge, see https://developer.sagebridge.org/.