I have a simple call to putObject :
bucket.putObject(params, function (err, data) {
if (err) {
results.innerHTML = 'ERROR: ' + err;
} else {
##What do I need here to return the url of the newly uploaded file.
}
});
Thanks
I got it,
I used :
var s3url = s3.getSignedUrl('getObject', {Key: params.Key});
Thanks
Actually, the url expires after a while how to get a url that doesn't expire?
@Hamada92
Is your object public to everyone, or is it private and you want to generate a URL to share to specific users?
The SDK provides s3.getSignedUrl as a way to do the latter, but signed urls have an expiration date. Otherwise, for a url to a public object that doesn't expire, that would have to be built manually. If you click on an object in the S3 console you can see an example of what that url would look like.
Yeah I ended up building the url manually like this :
var s3url = "https://s3.amazonaws.com/questionimagesjs/" + encodeURIComponent(file.name.replace(/ /g,''))
It works, my question is are there any edge cases where the name of the file will not be encoded into a valid URL?
Thanks
I'd love if this was provided by the sdk. I think the ruby sdk provided this url building method.
Another solution is to use upload instead of putObject. It will return public URL in Location key.
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread.
Most helpful comment
Another solution is to use upload instead of putObject. It will return public URL in Location key.