How to upload assets

Business Case:

KPI to be measured

Bookmark this resource Follow

Ask a question

Was this article helpful? 0 out of 0 found this helpful

Publishing a new content to THRON takes place starting from a physical file which extension will determine the content type: video, audio, image, document; in some cases the content type may be modified, for example you might want to upload an image as a document.

Loading this physical file can be performed using the GUI of THRON Dashboard, or using its APIs. The process of creating a new content begins with the phase of file selection with the subsequent upload to THRON repository. Even though the process of content creation passes through the use of a single web service, which is the insert,  the source file can be withdrawn from multiple origins: it can be uploaded using an FTP client, it may be also taken from a web resource, or directly from an S3 bucket.

 

Direct HTTP upload

 

You can add a file to the THRON’s repository via a direct HTTP upload by defining the following fields in the param.sources object in the request:


"sources": [{
   "raw": {
     "buffer": "",
      "mimeType": ""
    }
  }
]

 

This method will receive the file in the buffer parameter of the insert request body, add it to the repository and use it to publish the new content.

The service will return a response only upon the completion of the upload and only if the file has been accepted. Moreover, the submitted file must be smaller than 2MB.

 

Advantages:

  • quick and easy integration

Disadvantages:

  • can be used for small files only (2MB maximum).
  • synchronous (blocks the thread’s execution until completed), should be implemented in another thread not to block the frontend process.

 

Upload via FTP

 

This method involves the following two steps:

  1. Upload the file to the THRON’s FTP area (via a library or an external program). The credentials to access the FTP area can be found within the dashboard:

    FTPCredentials.gif

  2. Ask THRON to move the file from the FTP area to the sources’ repository and create the new content from this source

 

The second step is performed by defining the following fields in the param.sources object of the request:

 

"sources": [{
    "ftp": {
      "fileName": ""
    }
]

 

Once the file has been added to the repository, it will be removed from the FTP deposit area.

 

Advantages:

  • supports files up to 30GB
  • it allows you to handle large size files upload and manage simultaneous uploads

Disadvantages:

  • requires the use of an FTP client
  • synchronous (blocks the thread’s execution until completed), should be implemented in another thread to not block the frontend process

 

Web resource

 

You can ask THRON to fetch a web resource and add it as a new file in the sources’ repository; this case is achieved by defining the following fields in the param.sources object in the request:

 

"sources": [{
    "web": {
      "url": "",
      "newFileName": ""
    }
]

 

This method will try and retrieve the file from the provided URL, returning the details of the new source file.

This method is asynchronous; that is, when you add a web resource to the platform, the service will return the details of the newly created content. You should check periodically the state of this file to detect the error cases.

Another possibility is to add the web resource to platform and create the new content regardless of its state; in this case, the new content will be in an error state if the fetching of the web resource fails.

 

Advantages:

  • supports files up to 30GB
  • asynchronous (once fired, THRON will try and fetch the resource “on its own”)

Disadvantages:

  • it’s up to the integrator to check that the file has been successfully added to the repository
  • the server must be publicly accessible from the Internet; that is,
    • the THRON platform needs to be able to get the correct address from a public DNS server
    • The file will be requested with an HTTP GET request, so the server must be accessed on the HTTP port (typically 80 or 443)
    • in case of HTTPS transport, the certificate must be released from a known certificate authority.

 

File upload via S3 bucket

 

This method requires you to upload the file onto a S3 bucket and then notify its presence in the THRON content creation function. There are two distinct scenarios:

 

[dropdown:You already have control of an S3 bucket and you can upload files onto it]

In this case you will have to upload the file on your S3 bucket in the usual way and then ask THRON to add this content in the repository, specifying the bucket details by defining the following fields in the param.sources object in the request:

"sources": [{
    "s3": {
      "bucket": "<your bucket ID>",
      "filePath": "<the file path>",
      "newFileName": "<a new file name if needed>",
      "removeSourceFile": true,
      "accessKey": "<access key on the bucket>",
      "secretKey": "<secret key on the bucket>"
    }
]

 

Please note that you must provide an access key and a secret key which identify an user with (at least) read-only right on the file.[/dropdown]

[dropdown:You don’t have an S3 bucket and/or you’d like to use a temporary S3 bucket]

In this second case you need to ask THRON to provide you a temporary set of credentials:

  1. Get a set of temporary credentials for the upload of the file in a deposit AWS S3 bucket
    This step requires the invocation of the method repository/getS3UploadCredentials in the xpackager service; it will return a set of credentials to be used as the login details for the AWS S3 library (see Making Requests Using IAM User Temporary Credentials in the AWS SDK for Java documentation) and the bucket name and parent key to be used for the upload
  2. Upload the file to the bucket via the AWS S3 library on the bucket and with the parent key returned by the previous step
  3. Ask THRON to add this newly inserted content in the repository
    This step requires you to specify the temporary bucket details by defining the following fields in the sources object in the request:
"sources": [{
    "s3": {
      "bucket": "<the temporary bucket from getS3UploadCredentials>",
      "filePath": "<the temporary file path from the previous step>",
      "newFileName": "<a new file name if needed>",
      "removeSourceFile": true,
      "accessKey": "<the temporary access key from getS3UploadCredentials>",
      "secretKey": "<the temporary secret key from getS3UploadCredentials>"
    }
]

 

[/dropdown] 

Advantages:

  • supports files up to 30GB
  • quick and easy integration; lots of ready-to-use code samples
  • the AWS library is public, well maintained and well documented
  • the deposit area is temporary and it will be removed after the expiration of the credentials.
  • file transfer can be suspended and resumed at any time

Disadvantages:

  • the transfer to S3 is synchronous (blocks the thread’s execution until ended), it should be implemented in another thread to not block the frontend process.
  • provided credentials have a limited lifespan (1 hour).

 

All of these methods bear advantages and disadvantages; we suggest you to implement the upload via the S3 temporary bucket, since

  • the required integration is based on well-known and readily available libraries
  • you don’t need to know in advance the naming convention used for the FTP deposit
  • (most important) it is really a “temporary” deposit, enhancing the security of the transaction.
Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments