How to Use Pre-Signed URL in Node.js with Stook
Generate and use pre-signed URLs in Node.js for accessing objects in Medianova Stook Object Storage.
You can generate pre-signed URLs with the AWS SDK for Node.js to securely access or share objects stored in Medianova Stook Object Storage. Pre-signed URLs allow temporary access to your data without exposing credentials.
Prerequisites
Node.js installed on your system
AWS SDK for Node.js installed (
npm install aws-sdk
)Medianova Stook credentials:
Access Key
Secret Key
Endpoint
Example: Generate a Pre-Signed URL
var AWS = require('aws-sdk');
var config = {
s3ForcePathStyle: true,
};
var credentials = new AWS.SharedIniFileCredentials({
profile: 'medianova'
});
AWS.config.credentials = credentials;
AWS.config.update(config);
var ep = new AWS.Endpoint('customername.mncdn.com');
var s3 = new AWS.S3({endpoint: ep});
var myBucket = 'bucket';
var myKey = 'mykey';
var signedUrlExpireSeconds = 60 * 5;
var url = s3.getSignedUrl('getObject', {
Bucket: myBucket,
Key: myKey,
Expires: signedUrlExpireSeconds
});
console.log(url);
How It Works
Configure the AWS SDK with
s3ForcePathStyle
.Use your Medianova credentials (via profile or direct configuration).
Define bucket, object key, and expiration time.
Call
getSignedUrl('getObject', {...})
to generate a URL.Use or share the generated URL within its expiration time.
Troubleshooting / FAQ
Expired URL: Adjust
Expires
value (e.g.,60*10
for 10 minutes).Access denied: Verify bucket policy and Stook credentials.
Invalid endpoint: Ensure endpoint matches your Stook account.
References
Last updated
Was this helpful?