I am trying to do import from Url. I checked in example it’s working but it’s no working for me.
Here is my code
require(‘dotenv’).config()
const express = require(‘express’)
const companion = require(‘@uppy/companion’);
const path = require(‘path’);
const app = express()
const port = process.env.PORT ?? 9076
const bodyParser = require(‘body-parser’);
const session = require(‘express-session’);
const cors = require(‘cors’);
app.use(bodyParser.json());
app.use(
session({
secret: ‘hm@4544540’,
resave: true,
saveUninitialized: true,
}),
);
app.get(‘/design’, (req, res) => {
res.sendFile(path.join(__dirname, ‘public’, ‘index.html’));
});
const companionOptions = {
s3: {
getKey: (req, filename) => {
return ${process.env.COMPANION_AWS_PREFIX}${req.filename}
;
}, // Specify the S3 folder path
secret: process.env.COMPANION_AWS_SECRET, // Return secret key
key: process.env.COMPANION_AWS_KEY, // Pass access key directly
bucket: process.env.COMPANION_AWS_BUCKET, // Bucket name
region: process.env.COMPANION_AWS_REGION, // AWS region
},
providerOptions: {
key: {
key: ‘secret’,
secret:‘secret’,
},
drive: {
key: ‘key’,
secret: ‘secret’,
},
},
server: {
host: ‘localhost:’+port,
protocol: ‘http’
corsOrigins: [‘‘],
},
filePath: ‘./download’,
corsOrigins: [’’],
secret: ‘secret’,
debug: true,
};
const { app: companionApp } = companion.app(companionOptions);
app.use(cors({
origin: ‘*’, // Allow requests from your client app
//methods: [‘GET’, ‘POST’, ‘OPTIONS’, ‘PUT’, ‘DELETE’, ‘FETCH’],
}));
app.use((req, res, next) => {
res.setHeader(‘Access-Control-Allow-Origin’, req.headers.origin || ‘*’);
res.setHeader(
‘Access-Control-Allow-Methods’,
‘GET, POST, OPTIONS, PUT, PATCH, DELETE’,
);
res.setHeader(
‘Access-Control-Allow-Headers’,
‘Authorization, Origin, Content-Type, Accept’,
);
console.log(Received ${req.method} request for ${req.url}
);
next();
});
app.use(companionApp);
companion.socket(app.listen(port));
console.log(‘Welcome to Companion!’);
console.log(Listening on http://0.0.0.0:
+port);
// === </some plumbing to make the example work> ===