Skip to content

Upload

Nexus Upload API service allows users to upload files and retrieve previously uploaded files. This is useful for using data sources in Nexus that are not connected to the internet. With the Upload API users can manually upload files of such data sources or periodically upload using automation scripts.

List previously uploaded files

GET /uploads/
Retrieve a previously uploaded dataset.

It is possible to check previously uploaded files. Note that only the most recent upload for each datasource can be retrieved. Any response to this request will be a list. For each datasource that list contains the most recently uploaded file, a temporary download link (upload_file field), upload date, Nexus ID of the person who uploaded the file and Nexus Datasource ID.

Example

Request:

curl "https://nexus.stellaspark.com/api/v1/uploads/?token={web_api_token}"

Response:

[
    {
        "id": 104,
        "filename": "Dataset.csv",
        "uploader_name": "Data supplier X",
        "upload_file": {temp_download_link},
        "upload_date": "2021-01-18T12:55:11.930943+01:00",
        "uploader": 648464,
        "datasource": 373823,
        "datasource_name": "Dataset export",
        "datasource_owner": "Organization Y",
        "sync_last_finished": "2021-01-12T13:01:18Z",
        "sync_status": "harvesting"
    },
    {
        "id": 523,
        "filename": "0800_new_measurements.csv",
        "uploader_name": "Data supplier X",
        "upload_file": {temp_download_link},
        "upload_date": "2021-08-13T09:00:12.863775+02:00",
        "uploader": 582,
        "datasource": 37828276,
        "datasource_name": "Measurements export",
        "datasource_owner": "Organization Z",
        "sync_last_finished": "2021-08-13T10:01:10Z",
        "sync_status": "successful"
    }
]

Uploading a new file

POST /uploads/
Upload a new version of a data source.

In case of timeseries measurements, rasters or files (such as photos, documents or videos) the data will be appended to the currently stored data. Any overlapping data will be overwritten with the newest version (this upload).

Non-timestamped data (regular spatial datasets) will replace the data currently in Nexus. As such, the upload is considered to contain the 'latest version' of the data source.

The post-request should contain a parameter datasource with the Nexus Datasource ID and a parameter upload_file with a reference to the local file to be uploaded.

Example

Request:

curl -F "datasource=56516245" -F "upload_file=@C:/path/to/new/dataset.csv" "https://nexus.stellaspark.com/api/v1/uploads/?token={web_api_token}"

Response:

{
    "id": 104,
    "filename": "dataset.csv",
    "uploader_name": "Data supplier X",
    "upload_file": {temp_download_link},
    "upload_date": "2021-01-18T12:55:11.930943+01:00",
    "uploader": 648464,
    "datasource": 56516245,
    "datasource_name": "Dummy",
    "datasource_owner": "Organization Y",
    "sync_last_finished": "2021-01-12T13:01:18Z",
    "sync_status": "harvesting"
}

Warning

After uploading your file, Nexus sanitizes the filename for security reasons. Only alphanumeric characters (A-Z, a-z and 0-9), hyphens (-), dots (.) and underscores (_) are retained, any other character will be removed. For example; a filename like evaporation#2020-1-1.tif will become evaporation2020-1-1.tif after upload.

This is generally not a problem, as only the file contents matter. However, if the filename itself carries special meaning that is to be interpreted by Nexus, then this might get lost in the upload process.

If you have files with special characters in the filename and you want to retain them, consider zipping the file before uploading to ensure that the filename stays the same, or rename the files before uploading.

Info

Nexus accepts uploads up to a maximum size of 500 MB. Uploads may be submitted in a compressed archive (such as zip), containing multiple files of the same format. Nexus can process individual JSON files up to a maximum size of 100 MB.