Yash Bhor
Yash Bhor

Reputation: 1

How to upload files on HUAWEI OBS using Javascript

I am uploading files on HUAWEI Cloud. I have accessKey, secretKey, bucketName. While uploading I am getting error shown below:

Error uploading: Error: connect ETIMEDOUT XXX.XXX.XXX.X:8080

at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1494:16) at TCPConnectWrap.callbackTrampoline (node:internal/async_hooks:130:17) { errno: -4039, code: 'ETIMEDOUT', syscall: 'connect', address: 'XXX.XXX.XXX.X', port: 8080 }

Code for the same is const obs = new OBS();

obs.Factory(AccessKey, SecretKey, false, ServerURL, false, false, BucketRegion);
 const obsParams = {
       Bucket: BucketName,
       Key: file.originalname,
       Body: file.buffer
 };




 server.post('/api/initiateReconciliation', upload.single('file'), async (req, res) => {
     const file = req.file;
      obs.PutObject(obsParams, (err, data) => {
            if (err) {
               console.error('Error uploading:', err);
               res.status(500).json({ error: 'Error uploading file' });
               return;
            }
    res.status(200).json({ userMessage: 'OK', message: 'File uploaded successfully', url:                    data.Location });
        return;
      });
 });

Upvotes: 0

Views: 106

Answers (0)

Related Questions