Skip to main content

File upload

Overview

This set of RESTful API designed for managing file operations, including upload, download, and status checking and also searching the STAC layers. It is part of a larger system that handles file ingestion and tracking. The API is secured and requires appropriate permissions for access. All the APIs are secured and need API-Key to access them.

Please refer to the slide gIQ-Authentication for detailed instructions on how to generate the API key.


1. File Upload API

There are two methods for uploading files. For smaller files (up to 100MB), you can use Type 1, which allows you to upload the file directly. For larger files, it's recommended to use Type 2, where the file is uploaded in chunks and then combined. Detailed steps for both methods are provided in their respective sections.

1.1 Type 1 (Up to 100MB)

Endpoint

  • URL: https://giq.ae/public/file/upload
  • Method: POST
  • Produces: application/json

Description

This API allows users to upload a file for processing. File Upload Type 1 API is designed for uploading smalled files ( up to 100MB or lesser).

Permissions Required

At least one of the following permissions is required:

  • files_admin
  • files_upload

Request Parameters

NameTypeMandatoryDescription
fileMultipartFileYesThe file to be uploaded.
sourceTypeStringNoThe type of source from predefined source types. Default is UNKNOWN. Including it ensures more accurate file processing.

Possible Source Types

Possible Values
MULTISPECTRALPOINTGEOMETRYCOLLECTIONNETCDF
HYPERSPECTRALLINESTRINGTILES3DLAND_SUBSIDENCE
SARPOLYGONCOMPLEXPDF
FULL_MOTION_VIDEOHEIGHTMAPUNKNOWNIMAGE
PANCHROMATICTHERMALANNOTATIONCZML

Request Example (cURL)

curl --location 'https://giq.ae/public/file/upload?sourceType=IMAGE' \
--header 'X-API-KEY: apiKey' \
--form 'file=@"/Users/Downloads/test.png"'

Success Response

FieldTypeDescription
fileIdStringUnique identifier for the uploaded file.
originalNameStringThe original name of the uploaded file.
createdAtDateThe date and time when the file was uploaded.
sizeLongThe size of the uploaded file in bytes.

Success Response Example

{
"fileId": "UUID",
"originalName": "test.png",
"createdAt": "2024-09-17T10:30:00Z",
"size": 2048
}

Error Handling

Status CodeError MessageDescription
401 UnauthorizedUnauthorized RequestIndicates invalid credentials.
400 Bad RequestBad RequestIndicates an invalid request, such as a missing file.
403 ForbiddenPermission DeniedOccurs when the user lacks the required permissions (files_admin or files_upload).
500 Internal Server ErrorInternal Server ErrorIndicates a server error occurred while processing the request.

1.2 Type 2

Overview

File Upload Type 2 API is designed for uploading large files (up to ~10GB or larger) in chunks to ensure smooth uploads, especially when dealing with potential network interruptions. Chunked file uploads offer the following benefits:

  • Reduces the risk of failure due to network issues or timeouts.
  • Allows the ability to resume incomplete uploads.
  • Improves the reliability of uploading large files.
  • Optimizes bandwidth by retrying specific parts if needed.
  • Allows users the flexibility to upload chunks in sizes they define.

This API consists of three main steps:

  1. Generate an Upload ID – Initiates the multipart upload process.
  2. Upload File in Chunks – Uploads individual file chunks.
  3. Complete the Upload – Finalizes the upload process once all chunks are uploaded.

Step 1: Generate Upload ID

Endpoint
  • URL: https://giq.ae/public/file/generateUploadId
  • Method: POST
  • Produces: application/json
Description

Generates an Upload ID required for multipart file uploads. This Upload ID will be used in subsequent API calls for uploading file chunks and completing the upload.

Permissions Required

At least one of the following permissions is required:

  • files_admin
  • files_upload
Request Parameters
NameTypeRequiredDescription
fileNameStringYesThe name of the file to be uploaded.
Success Response

A JSON response containing the Upload ID and the file path (key) for the upload.

Success Response Example
{
"uploadId": "abcd1234",
"key": "path/to/your/file.extension"
}
Error Handling
Status CodeError MessageDescription
500 Internal Server ErrorFailed to generate upload IDIndicates a server error during the upload initiation process.

Step 2: Upload Chunk
Endpoint
  • URL: https://giq.ae/public/file/uploadChunk
  • Method: POST
  • Produces: application/json
Description

Uploads a chunk of the file as part of a multipart upload. This step is repeated for each chunk until the entire file is uploaded.

Request Parameters
NameTypeRequiredDescription
fileMultipartFileYesThe chunk of the file to be uploaded.
uploadIdStringYesThe unique ID generated from the /generateUploadId API.
partNumberIntegerYesThe part number for the chunk. Each chunk must have a unique part number.
keyStringYesThe file path (key) for the upload.
Success Response

A message confirming the chunk was uploaded successfully.

Success Response Example
{
"message": "Chunk uploaded successfully"
}
Error Handling
Status CodeError MessageDescription
500 Internal Server ErrorFailed to upload chunkIndicates a server error while uploading the file chunk.

Step 3: Complete Upload

Endpoint
  • URL: https://giq.ae/public/file/completeUpload
  • Method: POST
  • Produces: application/json
Description

This API completes the multipart upload process by assembling the uploaded file chunks into the final file and starts processing it.

Permissions Required

At least one of the following permissions is required:

  • files_admin
  • files_upload
Request Body
NameTypeRequiredDescription
uploadIdStringYesThe unique ID generated from the /generateUploadId API.
keyStringYesThe file path (key) generated from the /generateUploadId API.
fileSizeLongYesThe total size of the uploaded file in bytes.
sourceTypeSourceTypeYesThe source type of the file (refer to the enum above).
vectorMappingPropertiesJsonNodeNoOptional vector mapping properties for the file.
layerPropertiesJsonNodeNoOptional layer-specific properties.
geometryStringNoOptional geometry information related to the file.
acquisitionDateDateNoOptional acquisition date of the file.
Success Response
FieldTypeDescription
fileIdStringUnique identifier for the uploaded file.
originalNameStringThe original name of the uploaded file.
createdAtDateThe date and time when the file was uploaded.
sizeLongThe total size of the uploaded file in bytes.
Success Response Example
{
"fileId": "file1234",
"originalName": "example.png",
"createdAt": "2024-09-17T10:30:00Z",
"size": 10485760
}
Error Handling
Status CodeError MessageDescription
500 Internal Server ErrorFailed to complete uploadIndicates a server error during the completion process.
Notes
  • Ensure that the uploadId and key used in the request match the values generated during the upload initiation.

  • The system attempts to clean up any partially uploaded chunks in case of failure during the completion process.

  • If vector mapping or layer properties are relevant, they can be added to the request for more detailed file processing.

2. Get File Status

Overview

This API allows users to retrieve the status of a file by its unique identifier.

Endpoint

  • URL: https://giq.ae/public/file/status/{id}
  • Method: GET
  • Produces: application/json

Description

Retrieves the current status and metadata of a file based on its unique file ID.

Permissions Required

At least the following permission is required:

  • files_admin

Request Path Variables

NameTypeRequiredDescription
idStringYesThe unique identifier of the file which was generated by upload file API.

Request Example (cURL)

curl --location 'https://giq.ae/public/file/status/e098356c-bf59-11ee-a152-79143a5520da' \
--header 'X-API-KEY: apiKey'

Response

Response Fields

FieldTypeDescription
idStringUnique identifier of the file.
originalNameStringThe original name of the uploaded file.
statusStringThe current status of the file.
createdAtLongThe date and time when the file was created (in epoch milliseconds).

Sample Response

{
"id": "e098356c-bf59-11ee-a152-79143a5520da",
"originalName": "test.png",
"status": "COMPLETED",
"createdAt": 1706610323613
}

Error Handling

If an error occurs, appropriate status codes and error messages are returned.

Status CodeError MessageDescription
404 Not FoundFile not foundIndicates that the file with the given id does not exist.
500 Internal Server ErrorInternal Server ErrorIndicates a server error occurred while processing the request.

Error Response Example

{
"error": "File not found"
}

Notes

  • Ensure that the correct fileId is provided in the request to avoid a "File not found" error.
  • The status field reflects the current status of the file, such as QUEUED, IN_PROGRESS,COMPLETED or FAILED.

3. Download File URL

Overview

This API generates a pre-signed URL for downloading a file. The URL allows temporary access to download the file securely. Please note URL will be expired after 24 hours.


Endpoint

  • URL: https://giq.ae/public/file/download/url
  • Method: GET
  • Produces: text/plain

Description

Generates a pre-signed URL for downloading a file identified by its fileId. The user can optionally specify whether to use the default content type for the file.

Permissions Required

At least the following permission is required:

  • files_admin

Request Parameters

NameTypeRequiredDescription
fileIdStringYesThe unique identifier of the file( Which was generated by upload file api) to be downloaded.
useDefaultContentTypeBooleanNoOptional. If set to true, the file will be downloaded with the default content type. Default is false.

Request Example (cURL)

curl --location 'https://giq.ae/public/file/download/url?fileId=e098356c-bf59-11ee-a152-79143a5520da&useDefaultContentType=true' \
--header 'X-API-KEY: apiKey'

Response

The response will return a pre-signed URL in plain text format, which can be used to download the file.

Error Handling

If an error occurs, the API returns appropriate status codes and error messages.

Status CodeError MessageDescription
500 Internal Server ErrorInternal Server ErrorIndicates a server error occurred while processing the download request.

Notes

  • The pre-signed URL is temporary and will expire after 24Hours.
  • Ensure that the fileId provided is correct to avoid download issues.
  • The useDefaultContentType parameter is optional. If not provided, the default behavior is to return the file without enforcing a content type.