Dropsites are one of the multiple ways to upload media into AdmiralCloud. It is a low-threshold upload.
How to upload via Dropsite
In order to upload a media item via AdmiralCloud’s Dropsites, please follow this guide.
Before you start, make sure to that you have a device identifier. If you don’t have one, please create one or fetch one using TBC. Set the appropriate header for X-AdmiralCloud-Device.
Step 1 – Dropsite delivery
The first step is to fetch the dropsite content using Deliver Dropsite call. The response contains a clientId and a code. Please note, that the code has a limited timespan.
Make sure to set the clientId header based on the one you obtain from the response.
Step 2 – Generate token
Just prior to the upload, and only then, you should exchange the code for the token. If the code has expired please make the Dropsite deliver call again and retrieve a fresh code. If you request the dropsite token for the first time, you can decide whether to use the real user data for email, firstname and lastname or to generate random user data. The email address will returned and should be stored in your browser. This way subsequent Dropsite uploads will be linked to the same user.
If you already have an email address stored, just send it with the generate token request and the AdmiralCloud API will identify your user and return the appropriate session.
Please note, that session tokens have a limited timespan. Make sure to request a fresh token before this one times out. Please also note, that the session will be invalidated after you make the uploadComplete call.
Before you continue, make sure to set the provided access token as bearer header.
Step 3 – Create an upload document
Use S3.createUpload call to initiate an upload. Use the response to upload your media to the given destination. Make sure to call S3.success after every uploaded item and finally, after you have uploaded all items, call S3.uploadComplete.
In order to give visual feedback to logged in users (waiting for your upload), you might want to create and update activities (see Activity Controller).
Please remember – as soon as you make the S3.uploadComplete call, your token is invalidated and you can no longer sends data to our API. Please note that it is important to send this S3.uploadComplete call – otherwise the uploaded media items will be marked as “unsuccessful upload” and be automatically deleted.
Reference
Deliver Dropsite
Delivers a dropsite
Generate upload token
In order to upload to AdmiralCloud, you first have to generate a token, based on the code sent with the deliver response. This token is only valid until you call “uploadComplete”.
You can request the user to provide an e-mail address, a first name and a last name – but those fields are optional. If you use them, the user (and the upload) can be identified and linked to this user. If you do not send these data, a random user is created. It is recommended to store this user in your app, so not every time a dropsite upload is started, a new user is created.
After receiving the token, you can use API routes as described above in “How to upload via Dropsite”.
Upload started
Use this call to create an event if the dropsite started. The payload contains the total number of files, the total fileSize and information about the files. You can use it to send out an email with information on the upload.
{
"link": "3dgsd35aadg",
"uploadId": abd4-dd4-dfz4
"files": [
{ "fileName": "file001.jpg", fileSize: 1200 },
....
]
}