Temporary file storage techniques and benefits

Jonas, CTO

The ConvertAPI File Server is a temporary file cache that can be optionally used for file converters. It offers several benefits that simplify and expedite conversion requests, allowing for the reuse of files, enabling conversion chaining, and providing flexibility in downloading result files. Let's delve into each of these benefits in detail.

Benefits of Using the File Server

Performance

Files are uploaded to the file server using the octet-stream content type, which represents the raw file content in binary format. This ensures that files are transferred in the most efficient way possible.

POST https://v2.convertapi.com/upload?filename=myfile.docx
Content-Type: application/octet-stream
Content-Length: 1026736

<BINARY FILE CONTENT>
HTTP/1.1 200 OK
content-type: application/json
date: Thu, 08 Jun 2023 11:13:22 GMT

{
  "FileName": "myfile.docx",
  "FileExt": "docx",
  "FileSize": 1026736,
  "FileId": "odds8hk14hvqrvu0hki8b3dbupyuckt3",
  "Url": "https://v2.convertapi.com/d/odds8hk14hvqrvu0hki8b3dbupyuckt3"
}

After uploading, the file is assigned a unique file ID, which can be used as a parameter in conversion requests or as a URL query parameter.

POST https://v2.convertapi.com/convert/docx/to/pdf?Secret=<SECRET>
Content-Type: application/json
 
{
    "Parameters": [
        {
            "Name": "File",
            "FileValue": {
                "Id": "odds8hk14hvqrvu0hki8b3dbupyuckt3"
            }
        }
    ]
}

JSON-based conversion requests benefit greatly from this approach, as there is no need to include base64 encoded file contents within the JSON scheme. By using the file ID instead of the actual contents, JSON serialization and deserialization require fewer resources, resulting in improved overall performance.

File Reusability

When a file is uploaded to the File Server, it can be converted multiple times, even in parallel, without any additional performance loss. The same file can be referenced in conversion requests an unlimited number of times within a three-hour time span. Since the file is already stored on the server, it can be converted each time without the need for file transfer over the internet.

Conversion Chaining

The result files generated from conversions can be treated in the same way as uploaded files. By setting the StoreFile parameter to true, the result file can be obtained as a file ID or URL. The file ID of the result file is equivalent to the uploaded file ID, allowing it to be used in subsequent conversions. Stored result files are automatically removed after three hours, ensuring temporary storage and efficient resource management.

File URL

Files temporarily stored on the File Server can be securely accessed using a URL. This feature enables users to transfer the result file URL to other systems or provide it in a web browser for download. In the case of conversions that produce multiple files, an array of URLs is provided, allowing for parallel downloading and improved performance.

Security

The File Server resides on the same servers as our converters, utilizing IBM data centers that are secure and certified with multiple security certificates. Files are stored for a maximum of three hours and can be deleted at any time using the DELETE HTTP method. The File Server, like the rest of our service, is accessible via HTTPS, utilizing the best available encryption algorithms. Our SSL Labs assessment reflects an [A grade](https://www.ssllabs.com/ssltest/analyze.html?d=v2.convertapi.com), indicating our commitment to implementing the highest security standards. The file URL is protected by a unique 32-byte file ID, making it practically impossible to brute force. Considering the limited file storage time span of a maximum of three hours, this protection mechanism strengthens the overall security of the system. HTTPS ensures that both the URL and the rest of the request are encrypted and secure.

Closing Thoughts

The ConvertAPI File Server simplifies and accelerates file conversions. It optimizes performance by efficiently transferring files in binary format. Files can be reused for multiple conversions without performance loss. Result files can be treated like uploaded files, enabling conversion chaining.