5. API of Filesharing Service

5.1. HTTP Authentication
5.2. Upload and Download with Simple Identification
5.3. Upload and Download with Session Identification
5.4. Curl Example for Simple Upload Request
5.5. Upload Parameters
5.5.1. file
5.5.2. user
5.5.3. TTL
5.6. Number of Possible Downloads

5.1. HTTP Authentication

Type: Basic Auth
      username/password

5.2. Upload and Download with Simple Identification

The following HTTP methods can be used to perform file upload and download:

POST /uploads                                               // Simple upload

GET  /uploads/{fileId}                                      // Simple download

5.3. Upload and Download with Session Identification

The following HTTP methods can be used to perform file upload and download, and to manage sessions.

Session identification:

GET    /sessions/{sessionId}/files                            // Get all files of a session
GET    /sessions/{sessionId}/files/{fileId}/tokens/{tokenId}  // Download a single file

POST   /sessions                                              // Create a new session
POST   /sessions/{sessionId}/files                            // Create a new file entry
POST   /sessions/{sessionId}/files/{fileId}/tokens            // Generate a download token

PUT    /sessions/{sessionId}/files/{fileId}                   // Upload and store a file

Simple identification:

GET    /uploads/{fileId}                                      // Get uploaded file
POST   /uploads                                               // Upload file

5.4. Curl Example for Simple Upload Request

curl -i -X POST --insecure --form file=@/tmp/test.txt --user 'myuser@example.com:mypass' \
    https://$NGCP_IP:1446/rtc/fileshare/uploads

5.5. Upload Parameters

5.5.1. file

The parameter file defines the path to the desired file that should be uploaded.

caution

This upload parameter is mandatory!

Curl example:

curl -i -X POST --insecure --form file=@/tmp/test.txt https://$NGCP_IP:1446/rtc/fileshare/uploads
5.5.2. user

The parameter user defines the user to authenticate with the fileshare service.

caution

This upload parameter is mandatory!

curl -i -X POST --insecure --user 'foo:bar' https://$NGCP_IP:1446/rtc/fileshare/uploads
5.5.3. TTL

The parameter ttl defines the time-to-live (in seconds), that is how long the uploaded file will be available for download. The default values for this parameter are defined in the configuration file:

models: {
    session: {
        ttl: 86400 * 7
    },
    upload: {
        ttl: 3600
    }
}

Curl example:

curl -i -X POST --insecure --form file=@/tmp/test.txt --form ttl=3600 \
    --user 'foo:bar' https://$NGCP_IP:1446/rtc/fileshare/uploads

Response from curl when TTL is expired:

{
  "message": "upload expired"
}

Response in the log file when TTL is expired:

Error at /uploads/88e5905d-5d96-4750-ab3d-77a1ed26f569: message=upload expired, status=410

5.6. Number of Possible Downloads

There is a significant difference in the usage of the filesharing service between the approach within the RTC:engine and the simple upload/download one:

  • If you are using the simple upload and download approach, the generated download link you get for your file can be used as many times as required, as long as the TTL is not expired.
  • The approach with the Session ID, which will be used with the RTC:engine implementation, limits the download to one-time only. This means that the generated download link can be used only once. If you plan to share the URL with multiple persons, you have to generate one link for each recipient.