If anyone has any experience upgrading S3 from Sol...
# support
k
If anyone has any experience upgrading S3 from Solidus 2.11 with paperclip to Solidus 3.1, or if anyone has any working examples, it’d be greatly appreciated
t
Can you verify that
kt-paperclip
is in the
Gemfile.lock
? If not you need to add it to the bundle
👍 1
k
It is not
I will add now
What is kt-paperclip for?
And do I still need all the previous stuff e.g. attachment_config?
Unfortunately even with kt-paperclip I still get `NoMethodError: undefined method
has_one_attached' for #<Class:0x000055e04aa89258>
remote:    Did you mean? has_attached_file
r
solidus_core use to have
paperclip
as a dependency, but it changed to
kt-paperclip
in Solidus 3.0, see release log: https://github.com/solidusio/solidus/releases/tag/v3.0.0 https://github.com/solidusio/solidus/pull/3913
k
Okay, thanks. I have that in my gemfile at the moment, but not sure what else is required to get it workinge
My previous implementation was
aws-sdk
and:
Copy code
if Rails.env.production?
    attachment_config = {
      s3_credentials: {
        bucket:            ENV.fetch('S3_BUCKET_NAME'),
        access_key_id:     ENV.fetch('AWS_ACCESS_KEY_ID'),
        secret_access_key: ENV.fetch('AWS_SECRET_ACCESS_KEY')
      },

      storage:        :s3,
      s3_headers:     { 'Cache-Control' => 'max-age=31557600' },
      s3_protocol:    'https',
      s3_region:      ENV.fetch('AWS_REGION'),
      bucket:         ENV.fetch('S3_BUCKET_NAME'),
      url:            ':s3_domain_url',

      styles: {
        mini:    '128x128>',
        small:   '256x256>',
        product: '512x512>',
        large:   '1024x1024>'
      },

      path:          '/:class/:id/:style/:basename.:extension',
      default_url:   'noimage/:style.png',
      default_style: 'product',
    }

    attachment_config.each do |key, value|
      Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
    end
  end
I have currently moved to:
Copy code
`# Use AWS SDK for access to Amazon Web Services
gem "aws-sdk-s3", require: false

# Use Paperclip for easy file attachment management for ActiveRecord
gem "kt-paperclip", "~> 6.4", ">= 6.4.1"
Not sure if I still need:
Copy code
if Rails.env.production?
    attachment_config = {
      s3_credentials: {
        bucket:            ENV["S3_BUCKET_NAME"],
        access_key_id:     ENV["AWS_ACCESS_KEY_ID"],
        secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"]
      },

      storage:        :s3,
      s3_headers:     { "Cache-Control" => "max-age=31557600" },
      s3_protocol:    "https",
      s3_region:      ENV["AWS_REGION"],
      bucket:         ENV["S3_BUCKET_NAME"],
      url:            ":s3_domain_url",

      styles: {
        mini:    "128x128>",
        small:   "256x256>",
        product: "512x512>",
        large:   "1024x1024>"
      },

      path:          "/:class/:id/:style/:basename.:extension",
      default_url:   "noimage/:style.png",
      default_style: "product",
    }

    attachment_config.each do |key, value|
      Spree::Image.attachment_definitions[:attachment][key.to_sym] = value
    end
  end
Or do I need this adding?
Copy code
config.image_attachment_module = 'Spree::Image::ActiveStorageAttachment'
config.taxon_attachment_module = 'Spree::Taxon::ActiveStorageAttachment'
r
I am sorry, I am not experienced with S3 + kt-paperclip usage @Kurtis You might find some information here though: https://github.com/kreeti/kt-paperclip#storage
k
Thanks for all your help @Ryan Woods