I am following this example to carry on a silent migration from paperclip to active storage, in one piece of the code theres a call:
ActiveRecord::Base.transaction do
blob = ActiveStorage::Blob.create_after_upload!(
io: open(URI.parse(URI.escape("https://s3-#{ENV['AWS_AS_S3_REGION']}.amazonaws.com/#{ENV['AWS_AS_S3_BUCKET']}/" + key(picture_type.to_s)))),
filename: send("#{picture_type}_file_name"),
content_type: send("#{picture_type}_content_type")
)
blob.attachments.create(
name: picture_type.to_s,
record_type: self.class.name,
record_id: id
)
end
It worked out well for pretty much all paperclip attachments I had but just one type of URL is coming up with some errors, here an example link (not a real one, I changed the bucket name and the region):
URI.open(URI.parse(URI.decode( "https://s3-region.amazonaws.com/bucketname/photos/images/000/005/218/original/Desayuno_Barcelo%CC%81_Granada_Congress.jpg?1608043256" )))
this gives me the error:
URI::InvalidURIError (URI must be ascii only "https://s3-region.amazonaws.com/bucketname/photos/images/000/005/218/original/Desayuno_Barcelou0301_Granada_Congress.jpg?1608043256")
the decode doesn't seem to bring up the exact character since I get that
question from:
https://stackoverflow.com/questions/65922768/not-able-to-migrate-this-type-of-link-to-activestorage 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…