displayFailedUpload = (progressColumn=null) -> if progressColumn progressColumn.text("File could not be uploaded") else alert("File could not be uploaded") saveUrl = (container, uuid, filename, contentType, publicUrl) -> privateUrl = null $.ajax type: "POST" url: "/s3_relay/uploads" async: false data: parent_type: container.data("parentType") parent_id: container.data("parentId") association: container.data("association") uuid: uuid filename: filename content_type: contentType public_url: publicUrl success: (data, status, xhr) -> privateUrl = data.private_url error: (xhr) -> console.log xhr.responseText return privateUrl uploadFiles = (container) -> fileInput = $("input.s3r-field", container) files = fileInput.get(0).files uploadFile(container, file) for file in files fileInput.val("") uploadFile = (container, file) -> fileName = file.name $.ajax type: "GET" url: "/s3_relay/uploads/new" async: false success: (data, status, xhr) -> formData = new FormData() xhr = new XMLHttpRequest() endpoint = data.endpoint formData.append("AWSAccessKeyID", data.awsaccesskeyid) formData.append("x-amz-server-side-encryption", data.x_amz_server_side_encryption) formData.append("key", data.key) formData.append("success_action_status", data.success_action_status) formData.append("acl", data.acl) formData.append("policy", data.policy) formData.append("signature", data.signature) formData.append("content-type", file.type) formData.append("file", file) uuid = data.uuid uploadList = $(".s3r-upload-list", container) uploadList.prepend("
Your browser can't handle file uploads, please switch to Google Chrome.
")