generating signature
In the JQuery documentation (and elsewhere) there is a statement something like the following:
"However, Cloudinary requires upload requests to be signed with your private api_secret, which should not be exposed in public web pages. Therefore, a signature needs to be generated in your server-side application for authorizing direct uploading.
You can use Cloudinary's helper methods for generating the signature in various server frameworks: Ruby on Rails, PHP, Django and Node.js."
For whatever reason I am unable to find these helper methods. Searching the string "signature" comes up with very little. I'm using Coldfusion and very little exists in third party applications for CFM but usually I can take examples in PHP or Java and make do. For the life of me I cannot figure out how to generate this signature. I think I've got a pretty good idea of how it "probably" works but so far everywhere I see a reference to the needed signature it's basically just skipped over like it's a non-entity. Does anyone know specifically where I can see how these are generated?
Thank you!
-
You can read about how to generate the signature here:
http://cloudinary.com/documentation/upload_images#authenticated_imagesIn addition, here's the helper methods in PHP for example:
https://github.com/cloudinary/cloudinary_php/blob/master/src/Cloudinary.php#L7840 -
Thank you. The description at http://cloudinary.com/documentation/upload_images#request_authentication was easy to follow. I believe I have that part down now. Thanks again. Unfortunately I still can't upload an image with a simple form. I see in the comments in your JQuery info that people are asking for a dead simple example to follow as well. I've searched around and I cannot find any either. I see php help that is more built out with various options but a simple JQuery based image upload page would be a lot of help. Truly it needs to be a bare bones example of uploading an image - no extra options, no image manipulation - nothing. A good example of getting an image from a user's desktop to Cloudinary in the simplest possible way using JQuery would be a lot of help. Thank you.
PS. If you're available to look at it I can send you a link to my test page. Thanks.
0 -
Since signature generation is based on your API secret, which should not be revealed in your client-side code, the signature must be generated on the server-side. Therefore examples may vary from one framework to the other.
For example, we have a fully working PHP sample project, which demonstrates both server-side and client-side uploading:
https://github.com/cloudinary/cloudinary_php/tree/master/samples/PhotoAlbumYou're always welcomed to open a ticket and share your link with us, and we'll do our best to assist.
0 -
Do you have an asp.net c# example of generating signature?
0 -
You can have a look at our open source .NET integration library, i.e.,:
https://github.com/cloudinary/CloudinaryDotNet/blob/34d4f95a0e27b2b38fac73a29c04488c569fb224/Cloudinary/Api.cs#L4370 -
Do you have an example that get a signature from a node.js server... I'm have a bit trouble followint the docs... Thanks. Larry
0 -
Hi Larry,
Here's the reference code of generating the signature via our Node.js library's
api_sign_request
method:https://github.com/cloudinary/cloudinary_npm/blob/master/lib/utils.coffee#L352
0 -
i thought the support question i had might be best explained with some code. I am getting the same
{"error":{"message":"Missing required parameter - file"}}
I am generating the signed request following these instructions:
http://cloudinary.com/documentation/upload_images#request_authentication
everything looks to be correct in for client side form and on the nodejs server.. but i am still gettng a 400 error with the above json response
exports.signRequest = function(req, res){
//following these instructions
//http://cloudinary.com/documentation/upload_images#request_authentication
var public_id, ts, serialized_params, sha1hex_digest, js;public_id = "public_id=image_id";
ts = "timestamp=" + Math.round((new Date()).getTime() / 1000) + cloudinary.config().api_secret;
serialized_params = public_id + "&" + ts;
sha1hex_digest = cloudinary.utils.api_sign_request(serialized_params);
js = 'MerlinConfig.cloudinary = { "hash": \"' + sha1hex_digest + '\"}';res.end(js);
/*
the above res.end(js) outputs a js file ( <script src="http://localhost:3000/imageUpload/config.js"></script>) which sets the hash of the data-form-data
the data-form-data value in the below html is the result (i've obfuscated the hash but it looks like a correct hash)<form action="#">
<input type="file" class="cloudinary-fileupload" data-cloudinary-field="image\_id" data-module="images/upload" data-form-data="obfuscated-hash" data-options-hiddenfield="nameOfField1">
<input type="hidden" name="nameOfField1">
<div id="files" class="files panel upload-panel"></div>
</form>but i still get a
{"error":{"message":"Missing required parameter - file"}}
response from the server
*/
};0 -
i thought the support question i had might be best explained with some code. I am getting the same
{"error":{"message":"Missing required parameter - file"}}
I am generating the signed request following these instructions:
http://cloudinary.com/documentation/upload_images#request_authentication
everything looks to be correct in for client side form and on the nodejs server.. but i am still gettng a 400 error with the above json response
exports.signRequest = function(req, res){
//following these instructions
//http://cloudinary.com/documentation/upload_images#request_authentication
var public_id, ts, serialized_params, sha1hex_digest, js;public_id = "public_id=image_id";
ts = "timestamp=" + Math.round((new Date()).getTime() / 1000) + cloudinary.config().api_secret;
serialized_params = public_id + "&" + ts;
sha1hex_digest = cloudinary.utils.api_sign_request(serialized_params);
js = 'MerlinConfig.cloudinary = { "hash": \"' + sha1hex_digest + '\"}';res.end(js);
/*
the above res.end(js) outputs a js file ( <script src="http://localhost:3000/imageUpload/config.js"></script>) which sets the hash of the data-form-data
the data-form-data value in the below html is the result (i've obfuscated the hash but it looks like a correct hash)<form action="#">
<input type="file" class="cloudinary-fileupload" data-cloudinary-field="image\_id" data-module="images/upload" data-form-data="obfuscated-hash" data-options-hiddenfield="nameOfField1">
<input type="hidden" name="nameOfField1">
<div id="files" class="files panel upload-panel"></div>
</form>but i still get a
{"error":{"message":"Missing required parameter - file"}}
response from the server
*/
};0 -
Hi Chris,
You use our client integration libraries, most of the coding hassle will be done for you. For more information (in Node.js):
http://cloudinary.com/documentation/node_image_upload#direct_uploading_from_the_browserIn addition, we have fully working sample projects which demonstrate Cloudinary usage including client-side and server-side uploads, basic image manipulations and more. You're more than welcomed to test them out. For example, for Node.js:
https://github.com/cloudinary/cloudinary_npm/tree/master/samples/photo_albumIf you still require our assistance, please share a URL of a live webpage where this is used so we'll be able to further understand the issue.
0
Post is closed for comments.
Comments
10 comments