I have a web-app where I want users to directly upload to my own google cloud storage without having to go through an API. After some research, I've found out that you can temporarily give users access to your google cloud without them having to have a google account by using signed URLs. Since I want this to go on client-side, I tried to implement the signing using the javascript client library google has provided and some nodejs code that gets browserified. However, I am not entirely sure how to solve the issues that are:
-
How can I make the client read the pem file that is needed to sign the string? Since it's a local file and I'm aware that client-side code cannot easily access those.
-
After implementing a hack to read the file, how can I use that pem file to sign the string? I've tried to use a code I found on a different stackoverflow question but it gives me an "unknown message digest" error:
How do I solve these two issues?
Here's my code for the 2nd issue:
var stringPolicy = "POST\n" + "\n" + "\n" + expiry + "\n" + '/' + bucket;
var base64Policy = Buffer(stringPolicy, "utf8").toString("base64");
var signature = encodeURIComponent(crypto.createSign('sha256').update(stringPolicy).sign(privateKey,"base64"));
via Stefan Le Minh
No comments:
Post a Comment