From 0201595af39709d193a187be684a92bb86811095 Mon Sep 17 00:00:00 2001 From: 24c02 <163450896+24c02@users.noreply.github.com> Date: Tue, 3 Feb 2026 18:35:45 -0500 Subject: [PATCH] quota doc --- app/views/docs/pages/quotas.md | 6 ++-- lib/tasks/fix_content_disposition.rake | 44 ++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 lib/tasks/fix_content_disposition.rake diff --git a/app/views/docs/pages/quotas.md b/app/views/docs/pages/quotas.md index 922b14b..fd54d31 100644 --- a/app/views/docs/pages/quotas.md +++ b/app/views/docs/pages/quotas.md @@ -12,9 +12,9 @@ CDN provides free storage for the Hack Club community. Your quota depends on whe | Tier | Per File | Total Storage | |------|----------|---------------| -| **Unverified** | 10 MB | 50 MB | -| **Verified** | 50 MB | 50 GB | -| **Unlimited** | 200 MB | 300 GB | +| **Unverified** | 10 MB | 50 MB | +| **Verified** | 100 MB | 50 GB | +| **"Unlimited"** | 200 MB | 300 GB | **New users start unverified.** Once you verify with Hack Club, you automatically get 50GB. diff --git a/lib/tasks/fix_content_disposition.rake b/lib/tasks/fix_content_disposition.rake new file mode 100644 index 0000000..54067a2 --- /dev/null +++ b/lib/tasks/fix_content_disposition.rake @@ -0,0 +1,44 @@ +# frozen_string_literal: true + +namespace :storage do + desc "Update all existing blobs to have Content-Disposition: inline" + task fix_content_disposition: :environment do + require "aws-sdk-s3" + + service = ActiveStorage::Blob.service + unless service.is_a?(ActiveStorage::Service::S3Service) + puts "This task only works with S3/R2 storage. Current service: #{service.class}" + exit 1 + end + + client = service.client + bucket = service.bucket + + total = ActiveStorage::Blob.count + updated = 0 + errors = 0 + + puts "Updating Content-Disposition for #{total} blobs..." + + ActiveStorage::Blob.find_each.with_index do |blob, index| + print "\rProcessing #{index + 1}/#{total}..." + + begin + client.copy_object( + bucket: bucket.name, + copy_source: "#{bucket.name}/#{blob.key}", + key: blob.key, + content_disposition: "inline", + content_type: blob.content_type, + metadata_directive: "REPLACE" + ) + updated += 1 + rescue Aws::S3::Errors::ServiceError => e + puts "\nError updating #{blob.key}: #{e.message}" + errors += 1 + end + end + + puts "\nDone! Updated: #{updated}, Errors: #{errors}" + end +end