Project Files

Usually during a project plenty of files and reports are generated for various purposes.

Congrid system will automatically generate and store reports of all completed

  • measurements
  • inspections

Additionally automatic generation for reports can be configured for

  • notes
  • photos
  • public safety notes

In addition to system generated reports there are reports that are generated by manually by the end-user. These reports can be distinguished from each other through tags:

  • SYSTEM_GENERATED - the report is automatically generated by the system
  • USER_GENERATED - the report is manually generated by the user

Congrid API exposes end-points to fetch those files for backup or post-processing purposes. The API exposes two different ways for retrieving the measurements:

  • Retrieve files of a single project
  • Retrieve files of all projects

Both of these end-points are described below in more detail.

Fetching of file from Congrid system is a two step process not matter which of the above mentioned end-points the client application is using.

  1. Get the download link for the file
  2. Download the actual file

For the sake of this tutorial we have created two measurements.

Fetching files by project

To fetch the files for backup of other purposes use the following end-point

project/{{projectId}}/files

Request:

curl
JavaScript
curl -X GET -H "Content-Type: application/json" -H "Congrid-API-Token: YOUR-API-TOKEN" \
  "https://api.congrid.com/v1/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/files"
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.congrid.com/v1/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/files',
  headers: 
   { 'congrid-api-token': 'YOUR-API-TOKEN',
     'content-type': 'application/json' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response:

{
  "count": 2,
  "pageSize": 100,
  "results": [
    {
      "downloadUrl": "https://congrid.s3.amazonaws.com/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/reports/NR0IMGw7Jrg1K1ln3g4OeZ39teDtfi2F/TR_week_3_2017_Measurement-2__20170125-053758.pdf?Signature=XXX",
      "filename": "TR_week_3_2017_Measurement-2__20170125-053758.pdf",
      "id": "NR0IMGw7Jrg1K1ln3g4OeZ39teDtfi2F",
      "modifiedAt": "2017-01-25T05:37:58.360Z",
      "projectId": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ",
      "tags": [
        "TR_MEASUREMENT"
      ]
    },
    {
      "downloadUrl": "https://congrid.s3.amazonaws.com/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/reports/Jj22XGlYZBa87tcCU4yJfDqoAZgnCuBR/TR_week_4_2017_Measurement-1__20170125-053516.pdf?Signature=XXX",
      "filename": "TR_week_4_2017_Measurement-1__20170125-053516.pdf",
      "id": "Jj22XGlYZBa87tcCU4yJfDqoAZgnCuBR",
      "modifiedAt": "2017-01-25T05:35:16.256Z",
      "projectId": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ",
      "tags": [
        "TR_MEASUREMENT"
      ]
    }
  ]
}

The response shows the two reports generated for the measurements of the project. The downloadUrl of the file objects can be used to fetch the actual files.


NOTE

The download url is generated during the processing of the GET. It has a validity time and if the time is exceeded one needs to GET the files of the project again to generate a new valid download url


Lets download one actual file by using the downloadUrl from the previous response.

curl
JavaScript
curl -X GET -H "https://congrid.s3.amazonaws.com/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/reports/NR0IMGw7Jrg1K1ln3g4OeZ39teDtfi2F/TR_week_3_2017_Measurement-2__20170125-053758.pdf?Signature=XXX"
var request = require("request");

var options = { method: 'GET',
  url: 'https://congrid.s3.amazonaws.com/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/reports/NR0IMGw7Jrg1K1ln3g4OeZ39teDtfi2F/TR_week_3_2017_Measurement-2__20170125-053758.pdf',
  qs: 
   { Signature: 'sig',
     Expires: '1485410306',
     AWSAccessKeyId: 'XXX' },
  headers: { 'cache-control': 'no-cache' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Fetching files from a time period

To fetch files from a certain time range use the modifiedAtGt, modifiedAtGte, modifiedAtLt, modifiedAtLte query parameters.

A common approach is to automate the fetching of files for example on a daily basis. One could use the following queries to fetch the files from two subsequent days:

For the first day:

/projects/{projectId}/files?modifiedAtGte=2017-01-01T00:00:00&?modifiedAtLt=2017-01-02T00:00:00

For the second day:

/projects/{projectId}/files?modifiedAtGte=2017-01-02T00:00:00&?modifiedAtLt=2017-01-03T00:00:00

NOTE

The modifiedAt property of the file is set by the backend to the value when the file was generated.


Fetching files from all projects

The convenience end-point for fetching files from all the project in one go is:

/files

It accepts the same modifiedAtGt, modifiedAtGte, modifiedAtLt, modifiedAtLte query parameters as the per project end-point.

Example request:

curl
JavaScript
curl -X GET -H "Content-Type: application/json" -H "Congrid-API-Token: YOUR-API-TOKEN" \
  "https://api.congrid.com/v1/files"
var request = require("request");

var options = { method: 'GET',
  url: 'https://api.congrid.com/v1/files',
  headers: 
   { 'congrid-api-token': 'YOUR-API-TOKEN',
     'content-type': 'application/json' } };

request(options, function (error, response, body) {
  if (error) throw new Error(error);

  console.log(body);
});

Response:

{
  "count": 2,
  "pageSize": 100,
  "results": [
    {
      "downloadUrl": "https://congrid.s3.amazonaws.com/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/reports/NR0IMGw7Jrg1K1ln3g4OeZ39teDtfi2F/TR_week_3_2017_Measurement-2__20170125-053758.pdf?Signature=XXX",
      "filename": "TR_week_3_2017_Measurement-2__20170125-053758.pdf",
      "id": "NR0IMGw7Jrg1K1ln3g4OeZ39teDtfi2F",
      "modifiedAt": "2017-01-25T05:37:58.360Z",
      "projectId": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ",
      "tags": [
        "TR_MEASUREMENT"
      ]
    },
    {
      "downloadUrl": "https://congrid.s3.amazonaws.com/projects/PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ/reports/Jj22XGlYZBa87tcCU4yJfDqoAZgnCuBR/TR_week_4_2017_Measurement-1__20170125-053516.pdf?Signature=XXX",
      "filename": "TR_week_4_2017_Measurement-1__20170125-053516.pdf",
      "id": "Jj22XGlYZBa87tcCU4yJfDqoAZgnCuBR",
      "modifiedAt": "2017-01-25T05:35:16.256Z",
      "projectId": "PilvPWN3hZoNq4UOXVg6FFklXBJRTVzQ",
      "tags": [
        "TR_MEASUREMENT"
      ]
    }
  ]
}    

Note that the response is similar as in the the per project end-point because we only have created one project in the system.

results matching ""

    No results matching ""