import S3 , { GetObjectRequest } from "aws-sdk/clients/s3" ; import { Request } from "aws-sdk/lib/request" ; import { AWSError } from "aws-sdk/lib/error" ; import { S3URI } from "../../../shared/entities" ; export function s3Options ( path , fileName ) { const url = new URL ( path ) ; const pathWithoutLeadingSlash = url . pathname . substring ( 1 ) ; const options = { Bucket : url . hostname , Key : `${ pathWithoutLeadingSlash }${ fileName }` } ; return options ; } export function getObject ( s3 , req ) { const request = s3 . config . credentials ? s3 . getObject ( req ) : s3 . makeUnauthenticatedRequest ( "getObject" , req ) ; return request . promise ( ) ; }