Skip to content

Improve URL encoding in createFile() Location field #461

@coderabbitai

Description

@coderabbitai

Background

The Location field returned by createFile() in index.js currently uses raw params.Key without URL encoding. This is pre-existing behavior that should be improved to properly handle filenames with special characters (e.g., spaces, parentheses).

Problem

Filenames with spaces or special characters (e.g., my file (1).txt) produce technically malformed URLs in the Location field:

  • Current: https://bucket.s3.region.amazonaws.com/my file (1).txt
  • Expected: https://bucket.s3.region.amazonaws.com/my%20file%20(1).txt

Solution

Apply proper URL encoding to params.Key when constructing the Location URL, using:

params.Key.split('/').map(encodeURIComponent).join('/')

This matches the logic already used in getFileLocation() and avoids encoding path separators.

References

Metadata

Metadata

Assignees

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