oracle/oci-typescript-sdk

TypeError: Cannot read properties of undefined (reading 'ConfigFileAuthenticationDetailsProvider')

Closed this issue · 9 comments

Earlier I was uploading the file to Amazon S3 with the following code below.

const userMapFileUpload = multer({
  storage: multerS3({
    s3: new S3Client({
      region: process.env.AWS_REGION!,
      credentials: {
        accessKeyId: process.env.AWS_ACCESS_KEY_ID!,
        secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY!,
      },
    }),
    bucket: process.env.AWS_S3_BUCKET!,
    acl: 'public-read',
    key: (_, file, cb) => {
      const filenameDots = file.originalname.split('.');
      const filename = `mwatch${crypto.randomUUID()}.${
        filenameDots[filenameDots.length - 1]
      }`;

      cb(null, filename);
    },
  }),
  limits: {
    fileSize: 1024 * 1024 * 10, // 10 MB
  },
  fileFilter: (_, file, cb) => {
    const allowedMimes = [
      'image/jpeg',
      'image/jpg',
      'image/png',
      'image/JPG',
      'image/PNG',
    ];

    if (allowedMimes.includes(file.mimetype)) {
      cb(null, true);
    } else {
      cb(new Error('Invalid file type.'));
    }
  },
});

Now I would like to upload to a bucket on Oracle Cloud using the sdk, how should I proceed.

Hi @Paulo-P-33 ,

Oracle cloud (OCI) offers SDKs in various languages including TypeScript. You could use our native SDK to upload files to OCI Object Storage.

Here are a couple of resources:

  1. OCI TypeScript SDK - https://docs.oracle.com/en-us/iaas/Content/API/SDKDocs/typescriptsdk.htm
  2. Example code snippet - https://docs.oracle.com/en-us/iaas/api/#/en/objectstorage/20160918/Object/PutObject:~:text=Go%20SDK-,TypeScript%20SDK,-.NET%20SDK

We also support "Amazon S3 Compatibility APIs". So you could use the same code you are using now with AWS SDK but change the API endpoint to OCI object storage endpoint with OCI credentials.

Please see how to use Amazon S3 Compatibility APIs - https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/s3compatibleapi.htm

Hope this helps. Thanks.

How to get information about the authorization string charged in some requests?

For example Rest API at this link:
https://docs.oracle.com/en-us/iaas/api/#/en/s3objectstorage/20160918/Object/PutObject

Hi @Paulo-P-33 , can you clarify what you mean by "authorization string charged" ?

Where should I inform my credentials to make my request.

@Paulo-P-33 Can you clarify which client are you using? You seem to indicate you are using AWS TypeScript SDK with S3 and wanted to know if OCI has any options to do the same with OCI Object Storage. So I pointed out a couple of options we have.

So now are you trying it using REST client?

Also, the issue you created says "TypeError: Cannot read properties of undefined (reading 'ConfigFileAuthenticationDetailsProvider')". Can you clarify where are you seeing this error from?

Yes, now I'm trying to use REST Client.

Hi @Paulo-P-33 , which REST client are you using? It should have an authorization type selector that allows you to choose the auth type like API keys.

Hi @Paulo-P-33 , were you able to resolve the issue? I will close this out for now, please feel free to re-open if you run into issues again. Thanks.