[openstreetmap/openstreetmap-website] Compress plain GPX uploads with gzip (PR #7124)

Ruben L. Mendoza notifications at github.com
Fri Jul 17 22:19:02 UTC 2026


@Rub21 commented on this pull request.



> +        gz.binmode
+
+        writer = Zlib::GzipWriter.new(gz)
+        File.open(attachable.path, "rb") { |source| IO.copy_stream(source, writer) }
+        writer.finish
+        gz.rewind
+        # Delete the temp file from disk now, but keep gz open. Active Storage still
+        # reads this open handle to upload on save same as xml_file.
+        gz.unlink
+
+        # Flag server_gzipped=true, so the download and xml_file know the server gzipped it.
+        # Flag gzip_content_encoding=true only when the store puts a Content-Encoding: gzip
+        # header on the file (GpxS3). The download checks this flag on each file, so files
+        # uploaded without the header stay safe even if the storage service changes later.
+        metadata = { "server_gzipped" => true }
+        metadata["gzip_content_encoding"] = true if file_store_serves_content_encoding?

Good idea, I have not noticed that small part. now  the service sets the flag in upload_with_single_part and upload_with_multipart, right where it sets the header. The model only marks server_gzipped now, and I removed file_store_serves_content_encoding? since nothing uses it anymore.



-- 
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/7124#discussion_r3606508629
You are receiving this because you are subscribed to this thread.

Message ID: <openstreetmap/openstreetmap-website/pull/7124/review/4726489272 at github.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20260717/3309381e/attachment-0001.htm>


More information about the rails-dev mailing list