Skip to content

Instantly share code, notes, and snippets.

@rnicholus
Created July 8, 2016 20:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rnicholus/14afe7d05c60ef9cf2020b2d4fa2935b to your computer and use it in GitHub Desktop.
Save rnicholus/14afe7d05c60ef9cf2020b2d4fa2935b to your computer and use it in GitHub Desktop.
var uploader = new qq.s3.FineUploader({
element: document.getElementById("fineUploader"),
request: {
endpoint: "http://mybucket.s3.amazonaws.com",
accessKey: "MY_AWS_PUBLIC_ACCESS_KEY",
params: {category: "foobar"}
},
signature: {
endpoint: "/s3/signtureHandler"
},
uploadSuccess: {
endpoint: "/s3/uploadSuccessful"
},
iframeSupport: {
localBlankPagePath: "success.html"
},
objectProperties: {
key: function(fileId) {
var keyRetrieval = new qq.Promise(),
filename = encodeURIComponent(uploader.getName(fileId)),
xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if (xhr.readyState === 4) {
var status = xhr.status,
key = xhr.responseText;
if (status !== 200) {
keyRetrieval.failure();
}
else {
keyRetrieval.success(key);
}
}
}
xhr.open("POST", "createKey.html?filename=" + filename);
xhr.send();
return keyRetrieval;
}
},
validation: {
allowedExtensions: ["gif", "jpeg", "jpg", "png"],
acceptFiles: "image/gif, image/jpeg, image/png",
sizeLimit: 5000000,
itemLimit: 3
},
retry: {
enableAuto: true
},
chunking: {
enabled: true
},
resume: {
enabled: true
},
deleteFile: {
enabled: true,
endpoint: "/fileHandler"
},
paste: {
targetElement: document,
promptForName: true
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment