Uploaded Files
With the SDK, you can manage files uploaded by participants.
Query Uploaded Files
MyDataHelps.queryFiles(queryParameters)
Queries for uploaded files associated with the current participant.
Parameters
category
string
Queries files with the specified category.
uploadedAfter
date
Queries files uploaded after this date.
uploadedBefore
date
Queries files uploaded before this date.
limit
int
How many entries to include in each page of results. Default and maximum is 100.
pageID
string
Each page of results will return a nextPageID
if there are additional pages that can be queried. Supply that as pageID
to query the next page. When excluded, retrieves the first page.
Returns
Promise<UploadedFilePage>
Resolves to a result
object containing a page of file data.
+ Result Fields
result.files
collection
A list of UploadedFile objects filtered by the query parameters.
+ Element Fields
result.files[n].key
string
A primary key used to identify the file.
result.files[n].participantIdentifier
string
Project-set, unique participant identifier.
result.files[n].participantID
Internal, stable, unique ID for the participant.
result.files[n].category
string
An optional category used to group related files.
result.files[n].lastModified
date
Date (in UTC) when the file was last modified.
result.nextPageID
string
An ID to be used with subsequent queries. Results from queries using this ID as the pageID
parameter will show the next page of results. This field is null if there isn’t a next page.
Availability
var queryParameters = {
category: "images",
uploadedAfter: "2021-02-18",
limit: 3,
pageID: "gVWx3AtXMpsEXGd9NWVS"
};
MyDataHelps.queryFiles(queryParameters)
.then( function(result) {
console.log(result);
} );
var queryParameters = {
category: "images",
uploadedAfter: "2021-02-18",
limit: 3,
pageID: "gVWx3AtXMpsEXGd9NWVS"
};
MyDataHelps.queryFiles(queryParameters)
.then( function(result) {
console.log(result);
} );
{
"files": [
{
"participantID": "58b331cc-50ee-460b-8e7e-871e08867687",
"participantIdentifier": "PT-123",
"key": "58b331cc-50ee-460b-8e7e-871e08867687/images/2024-05-12T14:16:36.244Z_Kitty.jpg",
"category": "images",
"lastModified": "2024-05-12T10:16:37-04:00"
},
{
"participantID": "58b331cc-50ee-460b-8e7e-871e08867687",
"participantIdentifier": "PT-123",
"key": "58b331cc-50ee-460b-8e7e-871e08867687/files/2024-05-12T14:51:30.569Z_Llama.jpg",
"category": "workout-videos",
"lastModified": "2024-05-12T10:51:32-04:00"
},
...
],
"nextPageID": "A8MAqb65R6Ezx7NdzcND"
}
{
"files": [
{
"participantID": "58b331cc-50ee-460b-8e7e-871e08867687",
"participantIdentifier": "PT-123",
"key": "58b331cc-50ee-460b-8e7e-871e08867687/images/2024-05-12T14:16:36.244Z_Kitty.jpg",
"category": "images",
"lastModified": "2024-05-12T10:16:37-04:00"
},
{
"participantID": "58b331cc-50ee-460b-8e7e-871e08867687",
"participantIdentifier": "PT-123",
"key": "58b331cc-50ee-460b-8e7e-871e08867687/files/2024-05-12T14:51:30.569Z_Llama.jpg",
"category": "workout-videos",
"lastModified": "2024-05-12T10:51:32-04:00"
},
...
],
"nextPageID": "A8MAqb65R6Ezx7NdzcND"
}
Upload File
MyDataHelps.upload(file, category)
Uploads a file for the current participant.
Limitations:
- The maximum file size is 200MB.
- Only images, PDFs, audio files, and video files are allowed.
Parameters
category
string
An optional category used to group related files. May only contain alphanumeric characters and limited symbols: dot (.
), dash (-
), and underscore (_
).
Returns
Promise<UploadResponse>
Resolves to a result object containing the upload information.
+ Result Fields
result.preSignedUrl
string
A pre-signed URL offering secure, time-limited access to the file. The time the URL expires is embedded in the URL.
Availability
// file would typically come from a HTML file input element.
var file = document.getElementById('fileUpload').files[0];
MyDataHelps.upload(file, "images")
.then( function(result) {
console.log(result);
} );
// file would typically come from a HTML file input element.
var file = document.getElementById('fileUpload').files[0];
MyDataHelps.upload(file, "images")
.then( function(result) {
console.log(result);
} );
{
"preSignedUrl": "https://your-presigned-secure-image-url/58b331cc-50ee-460b-8e7e-871e08867687/image/2024-03-14T17:26:43.526Z_kitty.jpg?Expires=1715527513&various-access-credentials..."
}
{
"preSignedUrl": "https://your-presigned-secure-image-url/58b331cc-50ee-460b-8e7e-871e08867687/image/2024-03-14T17:26:43.526Z_kitty.jpg?Expires=1715527513&various-access-credentials..."
}
Get File Download URL
MyDataHelps.getFileDownloadUrl(key)
Returns a pre-signed URL that allows secure, time-limited access to download a file from the file store. Uses the key obtained from the queryFiles
method. The time the URL expires is embedded in the URL in the Expires
query parameter.
Parameters
key
string
(required)
Primary key for the file to download.
Returns
Promise<DownloadUrlResponse>
Resolves to a result object containing the download information.
+ Result Fields
result.preSignedUrl
string
A pre-signed URL offering secure, time-limited access to the file. The time the URL expires is embedded in the URL.
Availability
// You would usually get the key from a prior query request.
MyDataHelps.getFileDownloadUrl("58b331cc-50ee-460b-8e7e-871e08867687/images/2024-05-12T14:16:36.244Z_Kitty.jpg")
.then( function(result) {
console.log(result);
} );
// You would usually get the key from a prior query request.
MyDataHelps.getFileDownloadUrl("58b331cc-50ee-460b-8e7e-871e08867687/images/2024-05-12T14:16:36.244Z_Kitty.jpg")
.then( function(result) {
console.log(result);
} );
{
"preSignedUrl": "https://your-presigned-secure-image-url/58b331cc-50ee-460b-8e7e-871e08867687/image/2024-03-14T17:26:43.526Z_kitty.jpg?Expires=1715527513&various-access-credentials..."
}
{
"preSignedUrl": "https://your-presigned-secure-image-url/58b331cc-50ee-460b-8e7e-871e08867687/image/2024-03-14T17:26:43.526Z_kitty.jpg?Expires=1715527513&various-access-credentials..."
}
Delete File
MyDataHelps.deleteFile(key)
Deletes an uploaded file using the key obtained from the queryFiles
method.
Warning
This operation CANNOT be undone.
Parameters
key
string
(required)
Primary key for the file to delete.
Availability
// You would usually get the key from a prior query request.
MyDataHelps.deleteFile("58b331cc-50ee-460b-8e7e-871e08867687/images/2024-05-12T14:16:36.244Z_Kitty.jpg")
.then( function(result) {
console.log("File deleted.");
} );
// You would usually get the key from a prior query request.
MyDataHelps.deleteFile("58b331cc-50ee-460b-8e7e-871e08867687/images/2024-05-12T14:16:36.244Z_Kitty.jpg")
.then( function(result) {
console.log("File deleted.");
} );