Uploading Files in UGC


Agility provides a way to upload files into a CDN hosted for you website to help store files externally.

Version dependency Agility UGC v1.2.0 is required

File Type

File is of  input (type = file) element . The file object should have the following format:

File {name: "untitled-copy3.jpg", lastModified: 1600110139774, lastModifiedDate: Mon Sep 14 2020 15:02:19 GMT-0400 (Eastern Daylight Time), webkitRelativePath: "", size: 8779, …}
lastModified: 1600110139774
lastModifiedDate: Mon Sep 14 2020 15:02:19 GMT-0400 (Eastern Daylight Time) {}
name: "untitled-copy3.jpg"
size: 8779
type: "image/jpeg"
webkitRelativePath: ""
__proto__: File

Agility.UGC.API.UploadFile (JS)

Agility.UGC.API.UploadFile returns a relative URL to the uploaded file.

 Agility.UGC.API.UploadFile(file, "",
    function(uploadResponse) {
        if (uploadResponse.ResponseType == Agility.UGC.API.ResponseType.OK) {
            console.log(uploadResponse.ResponseData); //returns URL to file
        } else { //file upload was unsuccessful
    function(error) { //handle error
    function() { //handle always
    function(progress) { //handle progress (i.e progress returns state data on file upload)

To check if the file has been uploaded successfully go to URL: https://cdn.agilitycms.com/{uploadResponse.ResponseData}


UGC Definitions

UploadFile only uploads the file to then CDN and still needs to be set in the UGC record. When calling SaveRecord set the value of the 'File' field to the relative file URL (uploadResponse.ResponseData), do not append the https://cdn.agilitycms.com/.

0 out of 0 found this helpful



Please sign in to leave a comment.