Skip to content

Trailing slash on key is lost #762

@emil-rb

Description

@emil-rb

Problem

When using a trailing slash in the key the slash gets lost.

s3client = Aws::S3::Client.new(...)
s3client.put_object(key: 'path/with/trailing/slash/', bucket: 'bucket', body: '')

Actual behavior

An empty object with key path/with/trailing/slash is created.

Expected behavior

Create an empty object with key path/with/trailing/slash/ (note the trailing slash).

Use case

The use case for this is s3fs. It uses empty objects with trailing slashes to mark directories. Due to this issue objects created with this sdk are unusable from s3fs.

Debugging

I managed to track down the problematic piece of code.
aws-sdk-core/lib/seahorse/client/plugins/endpoint.rb, line 61:

param.split('/').map{ |value| escape(value) }.join('/')

This split-then-join loses the trailing slash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions