Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uploading files that share the same base filename to S3 can overwrite each other #294

Open
briansmith-epic opened this issue Aug 14, 2023 · 0 comments

Comments

@briansmith-epic
Copy link

When performing an upload via the SG API, we have multiple files that share a common filename but are in completely different paths. If we try to upload both of those simultaneously, the AWS upload URL is the same for both.

In _upload_to_storage(), os.path.basename(path) is passed to the _get_attachment_upload_info call. On the AWS side, that means that no matter the parent directory, any file that shares the base name will get a duplicate upload URL.

This only occurs if the _upload_to_storage() call happens concurrently : I'm guessing that the SG backend uses a timestamp to differentiate calls, because currently we do this about 30 times, but only when multiple get called at the same time do we get a duplicate upload URL.

The culprit line is here.

Recommend changing:
filename = os.path.basename(path)
to something like:
filename = os.path.abspath(path)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant