


Introduction
The 3 Clicks file API enables developers to interact with the 3 Clicks filesystem programatically.
Concept
User sends a request to 3 Clicks server
3 Clicks server creates a data entry for this request in the database and returns an AWS s3 upload policy to user
User uses this policy directly upload to AWS s3 bucket. When done, give 3 Clicks server a callback
3 Clicks server update this upload request status to done
Key points
User will upload a file directly to AWS S3, not to 3 Clicks server.
Upload can be done by HTML/js, PHP, or any other language support aws s3 API. In our example, we use HTML/js
End-user browser can be replaced by some other server-side script as well, doesn't have to be a browser.
User needs some program to talk to 3 Clicks API first. In our example, we use PHP as user side server script.
Related parties
[3 Clicks Server]: generate AWS S3 policy, initialize upload request
[AWS S3]: file storage
[Your Server]: talk to 3 Clicks server to get the S3 policy, has 3 Clicks API key/secret, talke to end-user browser
[End-User Browser(or other server-side script)]: actual file upload
File Upload Example
Please use ApiUploadFileDemo.7z for this example
You can rewrite demo server-side code or end-user code with the language you prefer, as long as it can send the right HTTP API talk with 3 Clicks server, can talk to aws S3 API.

Server Side Setup
unzip ApiUploadFileDemo.7z to a server with php 7.4 support
update config with your own 3 Clicks API key/secret

How to use Html PageHTML
Open the demo page (replace with your own domain and path)
Select upload target: order or style.
Fill target item number (order number/style number)
Select file and click upload button

How Tech Details work
There are three api talk sessions between your script and 3 Clicks Cloud server.
From your server side to 3 Clicks server, get s3 url and aws access id.
When the end-user click upload button, your script will talk to 3 Clicks server to get s3 policy parameters. Now the end-user will upload file to aws s3 directly.
When end-user file upload is complete the end-user html page will fire a callback to your server script, your script will talk to 3 Clicks server, let 3 Clicks know file upload has been successfully completed.