Skip to content

No ability to create 0 byte folder in S3 #4069

@kevinleadoutlabs

Description

@kevinleadoutlabs

Describe the bug

Trying to create a zero byte folder in S3 (as you can do in the console) but the trailing "/" always gets striped.

Steps To Reproduce

let folderPath = "test/"
let path = StringStoragePath.fromString(folderPath)
print("path: \(path.resolve(""))")
let options = StorageUploadDataRequest.Options(
    contentType: "application/x-directory"
)
let folderTask = Amplify.Storage.uploadData(
    path:path,
    data:Data(),
    options:options
)
_ = try await folderTask.value
logger.verbose("path created: \(result)")

Expected behavior

create a zero byte folder (trailing back slash)

Amplify Framework Version

2.51.1

Amplify Categories

Storage

Dependency manager

Swift PM

Swift version

6.2

CLI version

N/A

Xcode version

26.0.1

Relevant log output

both print statements reference that "test/" was created.

Is this a regression?

No

Regression additional context

this worked fine in the old SDK when I was using: guard let putObjectRequest = AWSS3PutObjectRequest() else {
throw NSError(domain: "AWSS3Error", code: -1, userInfo: [NSLocalizedDescriptionKey: "Failed to create PutObjectRequest"])
}
putObjectRequest.bucket = bucket
putObjectRequest.key = finalFolderPath
putObjectRequest.body = "".data(using: .utf8)

    if debug{
        logger.debug("attempting creation of: \(pathDisplay)")
    }
    
    try await s3.putObject(putObjectRequest) 

Platforms

No response

OS Version

26.0

Device

iPhone 7 (Simulator)

Specific to simulators

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionGeneral questionstorageIssues related to the Storage category

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions