Virtual-hosted-style requests

Hi!

I’m trying to set up file uploads to s3 storage by companion. I need to use vHosted style requests, but i can’t figure out how to do this. I tried using option forcePathStyle and it didn`t help me.

I need url like <container_name>.<s3_domain>, but now companion give: <s3_domain>/<container_name>.

Thanks!

hi. did you try the COMPANION_AWS_BUCKET and COMPANION_AWS_ENDPOINT options? they should let you specify the s3 URL

Hi! yes, here is my code example:

export const companionOptions = {
  debug: true,
  filePath: "/tmp",
  uploadUrls: ["https://<container_name>.<s3_domain>"],

  server: {
    host: process.env.ROOT_URL,
    protocol: `http${isDevelopment ? "" : "s"}`,
    path: "/uploads",
  },

  s3: {
    key: process.env.AWS_ACCESS_KEY_ID,
    secret: process.env.AWS_SECRET_ACCESS_KEY,
    endpoint: "<s3_domain>",
    bucket: "<container_name>",
    region: "<region>",
    acl: "private",
    conditions: [],
    getKey: ({ filename }: { filename: string }) => `${filename}`,
    forcePathStyle: true,
    awsClientOptions: {
      apiVersion: "latest",
    },
  },

  secret: process.env.COMPANION_SECRET,

  corsOrigins: false,
};

so it doesn’t work if you set endpoint: 'https://<container_name>.<s3_domain>'?