Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Remove need to store file data in the database using active storage.
Matthew Kennedydfbcd8eab0a8
diff --git a/api/app/controllers/spree/api/v2/storefront/digitals_controller.rb b/api/app/controllers/spree/api/v2/storefront/digitals_controller.rbindex 65749de8f7..40d0e5ff91 100644--- a/api/app/controllers/spree/api/v2/storefront/digitals_controller.rb+++ b/api/app/controllers/spree/api/v2/storefront/digitals_controller.rb@@ -8,8 +8,8 @@ module Spreeif digital_link.authorize!send_file(ActiveStorage::Blob.service.path_for(attachment.key),- filename: attachment.record.attachment_file_name,- type: attachment.record.attachment_content_type,+ filename: attachment.filename.to_s,+ type: attachment.content_type.to_s,status: :ok) and returnenddiff --git a/api/app/serializers/spree/api/v2/platform/digital_serializer.rb b/api/app/serializers/spree/api/v2/platform/digital_serializer.rbindex 486219c739..98826aea57 100644--- a/api/app/serializers/spree/api/v2/platform/digital_serializer.rb+++ b/api/app/serializers/spree/api/v2/platform/digital_serializer.rb@@ -5,13 +5,23 @@ module Spreeclass DigitalSerializer < BaseSerializerset_type :digital- attributes :attachment_file_name, :attachment_file_size, :attachment_content_type-attribute :url do |digital|url_helpers = Rails.application.routes.url_helpersurl_helpers.polymorphic_url(digital.attachment, only_path: true)end+ attribute :content_type do |digital|+ digital.attachment.content_type+ end++ attribute :filename do |digital|+ digital.attachment.filename+ end++ attribute :byte_size do |digital|+ digital.attachment.byte_size+ end+belongs_to :variantendenddiff --git a/core/db/migrate/20210929093238_create_spree_digitals.rb b/core/db/migrate/20210929093238_create_spree_digitals.rbindex 45d0bf583e..443cb05f78 100644--- a/core/db/migrate/20210929093238_create_spree_digitals.rb+++ b/core/db/migrate/20210929093238_create_spree_digitals.rb@@ -2,9 +2,6 @@ class CreateSpreeDigitals < ActiveRecord::Migration[5.2]def changecreate_table :spree_digitals, if_not_exists: true do |t|t.belongs_to :variant- t.string :attachment_file_name- t.string :attachment_content_type- t.integer :attachment_file_sizet.timestampsend