{"error":{"message":"UnknownAPIkey"}}
Has anyone come across this when trying to use the jquery sdk and php to work out the signature?
Thanks
-
This usually means the fileupload field has not been properly initialized, specifically, the parameters that go into formData have not been properly set.
Are you trying to set the data-form-data in javascript? If so, see http://support.cloudinary.com/entries/24950218-Why-is-updating-a-cloudinary-fileupload-field-dynamically-not-working-
For general documentation about direct uploads from the browser using PHP see http://cloudinary.com/documentation/php_image_upload#direct_uploading_from_the_browser
0 -
Hi, No I am not trying to set the data-form-data via javascript I have it being passed in from the server side. Looking at the post you recommended I have swapped the json string to the parameter hash.
$.cloudinary.config({"api_key":"","cloud_name": ""});
$(document).ready(function() {
//$(".cloudinary-fileupload").attr("data-form-data", "api_key=<key>&callback=<url>/cloudinary_cors.html&public_id=2c68ebf2f34d1b09&signature=c37ab1b130c43326179a8c58eb339f0bda95b4e8×tamp=1375449516");$('.cloudinary-fileupload').fileupload({
formData:"api_key=<key>&callback=http://www.barryburrows.com/cloudinary_cors.html&public_id=df7aee9fd8f39080&signature=c37ab1b130c43326179a8c58eb339f0bda95b4e8×tamp=1375449516",
start: function (e) {
$('.status_value').text('Starting direct upload...');
},
progress: function () {
$('.status_value').text('Uploading...');
},
done: function (e, data) {
$.each(data.result.files, function (index, file) {
$('<p/>').text(file.name).appendTo('#filename');
});
},
progressall: function (e, data) {
var progress = parseInt(data.loaded / data.total * 100, 10);
$('.progress_bar').css('width',progress + '%');
},
fail: function (e, data) {
//$(".status").text(JSON.stringify(data));
//$.each(Object.keys(data),function(i,val){
// $(".preview").append("<p>" + val + "</p>");
//});
alert(data.data);
alert(data.errorThrown);}
});});
As a result I then get an Unauthorized response.
I have added the configuration settings outside of the document.ready after reading another post about that being an issue.
0 -
The parameter formData needs to be a hash and not query-string serialized.
If you are generating it from PHP, it's the result of:
$params = Cloudinary\Uploader::build_upload_params($options);
$params = Cloudinary::sign_request($params, $options);
encoded as a Javascript hash.
Another option is to use cl_image_upload_tag and let it create the entire input tag.
0
Post is closed for comments.
Comments
3 comments