amazon-web-servicespowershelluploadaws-toolkit

Upload file to AWS S3 Bucket Subfolder with PowerShell


I am trying to upload a file to an existing folder within an S3 bucket using PowerShell

I've tried the following:

Write-S3Object -BucketName MyBucketName -Key Folder/Subfolder/MyFile.txt -File $filepath

Write-S3Object -BucketName MyBucketName -Key Folder/Subfolder/ -File $filepath

Write-S3Object -BucketName MyBucketName -Key Folder/Subfolder -File $filepath

In both instances, the code creates a NEW folder instead of accessing the EXISTING folder. I know I cannot include the path in the bucket name but using -Key is just creating new folders. I can't find a solution for this. Any ideas?


Solution

  • S3 isn't like NTFS or AFS and doesn't have folders. The S3 API doesn't use regular hierarchical file system semantics.

    The key you specify needs to be the key of the destination S3 object e.g. dogs/domestic/spaniel.png.