Replies: 1 comment
-
this is error I receive {"date":"Sun Jul 02 2023 11:18:17 GMT+0000 (Coordinated Universal Time)","error":{},"exception":true,"level":"error","message":"uncaughtException: Unexpected token '?'\n/home/ubuntu/Settle/node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/EndpointParameters.js:7\n useFipsEndpoint: options.useFipsEndpoint ?? false,\n ^\n\nSyntaxError: Unexpected token '?'\n at wrapSafe (internal/modules/cjs/loader.js:915:16)\n at Module._compile (internal/modules/cjs/loader.js:963:27)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n at Module.load (internal/modules/cjs/loader.js:863:32)\n at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n at Module.require (internal/modules/cjs/loader.js:887:19)\n at require (internal/modules/cjs/helpers.js:74:18)\n at Object. (/home/ubuntu/Settle/node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js:18:30)\n at Module._compile (internal/modules/cjs/loader.js:999:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)","os":{"loadavg":[0.61,0.24,0.09],"uptime":3217992.35},"process":{"argv":["/usr/bin/node","/home/ubuntu/Settle/index.js"],"cwd":"/home/ubuntu/Settle","execPath":"/usr/bin/node","gid":1000,"memoryUsage":{"arrayBuffers":36308309,"external":37940850,"heapTotal":37044224,"heapUsed":28427184,"rss":78561280},"pid":552144,"uid":1000,"version":"v12.22.9"},"stack":"/home/ubuntu/Settle/node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/EndpointParameters.js:7\n useFipsEndpoint: options.useFipsEndpoint ?? false,\n ^\n\nSyntaxError: Unexpected token '?'\n at wrapSafe (internal/modules/cjs/loader.js:915:16)\n at Module._compile (internal/modules/cjs/loader.js:963:27)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)\n at Module.load (internal/modules/cjs/loader.js:863:32)\n at Function.Module._load (internal/modules/cjs/loader.js:708:14)\n at Module.require (internal/modules/cjs/loader.js:887:19)\n at require (internal/modules/cjs/helpers.js:74:18)\n at Object. (/home/ubuntu/Settle/node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js:18:30)\n at Module._compile (internal/modules/cjs/loader.js:999:30)\n at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)","timestamp":"2023-07-02T11:18:17.219Z","trace":[{"column":16,"file":"internal/modules/cjs/loader.js","function":"wrapSafe","line":915,"method":null,"native":false},{"column":27,"file":"internal/modules/cjs/loader.js","function":"Module._compile","line":963,"method":"_compile","native":false},{"column":10,"file":"internal/modules/cjs/loader.js","function":"Module._extensions..js","line":1027,"method":".js","native":false},{"column":32,"file":"internal/modules/cjs/loader.js","function":"Module.load","line":863,"method":"load","native":false},{"column":14,"file":"internal/modules/cjs/loader.js","function":"Module._load","line":708,"method":"_load","native":false},{"column":19,"file":"internal/modules/cjs/loader.js","function":"Module.require","line":887,"method":"require","native":false},{"column":18,"file":"internal/modules/cjs/helpers.js","function":"require","line":74,"method":null,"native":false},{"column":30,"file":"/home/ubuntu/Settle/node_modules/@aws-sdk/client-s3/dist-cjs/S3Client.js","function":null,"line":18,"method":null,"native":false},{"column":30,"file":"internal/modules/cjs/loader.js","function":"Module._compile","line":999,"method":"_compile","native":false},{"column":10,"file":"internal/modules/cjs/loader.js","function":"Module._extensions..js","line":1027,"method":".js","native":false}]} |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
const { createPresignedPost } = require("@aws-sdk/s3-presigned-post");
const { S3Client } = require("@aws-sdk/client-s3");
const express = require('express');
const router = express.Router();
const uuid = require('uuid');
const auth =require('../middleware/auth');
const config = require('config');
router.get('/',auth,async(req,res)=>{
const key =
${req.user._id}/${uuid.v1()}.jpeg
;const client = new S3Client({ region: "ap-south-1" });
const { url, fields } = await createPresignedPost(client, {
Bucket:config.get('bucketName'),//make it secret also additional security
ContentType:'image/jpeg',
signatureVersion:'v4',
Key:key,
Expires: 600, //Seconds before the presigned post expires. 3600 by default.
});
module.exports = router;
node_modules/@aws-sdk/client-s3/dist-cjs/endpoint/EndpointParameters.js. The specific error is "SyntaxError: Unexpected token '?'". This error typically occurs when using the optional chaining operator (??) or nullish coalescing operator (??) in a version of Node.js that doesn't support them.
Beta Was this translation helpful? Give feedback.
All reactions