[openstreetmap/openstreetmap-website] Compress plain GPX uploads with gzip (PR #7124)
Ruben L. Mendoza
notifications at github.com
Fri Jun 5 23:11:11 UTC 2026
@Rub21 commented on this pull request.
> @@ -76,10 +78,26 @@ def tagstring=(s)
def file=(attachable)
case attachable
when ActionDispatch::Http::UploadedFile, Rack::Test::UploadedFile
- super(:io => attachable,
- :filename => attachable.original_filename,
- :content_type => content_type(attachable.path),
- :identify => false)
+ type = content_type(attachable.path)
+
+ if type == "application/gpx+xml"
+ # Gzip plain GPX before upload to S3
+ gz = Tempfile.new(["trace", ".gpx.gz"])
A block doesn't work here. Active Storage uploads on save and reads the file again then, so it needs to stay open until that point. Instead I unlink the temp file right after writing it. It's gone from disk, but the open handle still works for the upload. Same as xml_file function uses.
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7124#discussion_r3365855825
You are receiving this because you are subscribed to this thread.
Message ID: <openstreetmap/openstreetmap-website/pull/7124/review/4440367768 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260605/681ad196/attachment.htm>
More information about the rails-dev
mailing list