Ruby on rails Rails 5-检索图像的MiniMagick ed版本(CarrierWave/Google云存储)

Ruby on rails Rails 5-检索图像的MiniMagick ed版本(CarrierWave/Google云存储),ruby-on-rails,google-cloud-storage,carrierwave,Ruby On Rails,Google Cloud Storage,Carrierwave,我目前正在使用谷歌云存储和CarrierWave来处理我的文件上传 为了能够清楚地解释“问题”,让我们假设我有一个名为User的模型,它有一列avatar,其中包含图像字符串 用户上载其文件后,将执行以下操作: version :foo1 do process :auto_orient process resize_to_fill: [150, 150] end version :foo2 do process :auto_orient process resize_to_fi

我目前正在使用谷歌云存储和CarrierWave来处理我的文件上传

为了能够清楚地解释“问题”,让我们假设我有一个名为
User
的模型,它有一列
avatar
,其中包含图像字符串

用户上载其文件后,将执行以下操作:

version :foo1 do
  process :auto_orient
  process resize_to_fill: [150, 150]
end

version :foo2 do
  process :auto_orient
  process resize_to_fill: [250, 250]
end

version :foo3 do
  process :auto_orient
  process resize_to_fill: [350, 350]
end
它成功地在我的bucket中创建了不同版本的图像

所以问题是当我查看日志时,我意识到

<%= image_tag(User.avatar.foo1.url) %>

@你是否包含了这个
包含CarrierWave::MiniMagick
?可能看到这个它可以帮助你@Gabbar这个教程并没有真正的帮助,因为它没有使用谷歌云存储。。。我不确定这些图像的调用是否与AWS类似。但是,是的,我正在使用mini-magick,它允许我成功地调整和保存图像副本的大小。
Sending HTTP get https://www.googleapis.com/storage/v1/b/foo?
200
#<Hurley::Response GET https://www.googleapis.com/storage/v1/b/foo == 200 (374 bytes) 69ms>
Success - #<Google::Apis::StorageV1::Bucket:foo
 @etag="CAI=",
 @id="foo",
 @kind="storage#bucket",
 @location="ASIA-SOUTHEAST1",
 @metageneration="2",
 @name="foo",
 @project_number="foo",
 @self_link="https://www.googleapis.com/storage/v1/b/foo",
 @storage_class="NEARLINE",
 @time_created=Wed, 20 Dec 2017 05:50:41 +0000,
 @updated=Wed, 20 Dec 2017 07:08:46 +0000>

Sending HTTP get https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2FWeChat_Image_20180112102430.jpg?
200
#<Hurley::Response GET https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2FWeChat_Image_20180112102430.jpg == 200 (926 bytes) 62ms>
Success - #<Google::Apis::StorageV1::Object:0x007f98b3332220
 @bucket="foo",
 @content_type="image/jpeg",
 @crc32c="5SNA/w==",
 @etag="CNrr8om4h9sCEAE=",
 @generation="1526377710663130",
 @id=
  "foo/uploads/profile/avatar/328/WeChat_Image_20180112102430.jpg/1526377710663130",
 @kind="storage#object",
 @md5_hash="g6cUQBBiGC31uRJUtM1dng==",
 @media_link=
  "https://www.googleapis.com/download/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2FWeChat_Image_20180112102430.jpg?generation=1526377710663130&alt=media",
 @metageneration="1",
 @name="uploads/profile/avatar/328/WeChat_Image_20180112102430.jpg",
 @self_link=
  "https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2FWeChat_Image_20180112102430.jpg",
 @size="5499",
 @storage_class="NEARLINE",
 @time_created=Tue, 15 May 2018 09:48:30 +0000,
 @time_storage_class_updated=Tue, 15 May 2018 09:48:30 +0000,
 @updated=Tue, 15 May 2018 09:48:30 +0000>

Sending HTTP get https://www.googleapis.com/storage/v1/b/foo?
200
#<Hurley::Response GET https://www.googleapis.com/storage/v1/b/foo == 200 (374 bytes) 53ms>
Success - #<Google::Apis::StorageV1::Bucket:foo
 @etag="CAI=",
 @id="foo",
 @kind="storage#bucket",
 @location="ASIA-SOUTHEAST1",
 @metageneration="2",
 @name="foo",
 @project_number="foo",
 @self_link="https://www.googleapis.com/storage/v1/b/foo",
 @storage_class="NEARLINE",
 @time_created=Wed, 20 Dec 2017 05:50:41 +0000,
 @updated=Wed, 20 Dec 2017 07:08:46 +0000>

Sending HTTP get https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2Fthumb_WeChat_Image_20180112102430.jpg?
200
#<Hurley::Response GET https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2Fthumb_WeChat_Image_20180112102430.jpg == 200 (950 bytes) 58ms>
Success - #<Google::Apis::StorageV1::Object:foo
 @bucket="foo",
 @content_type="image/jpeg",
 @crc32c="XDUTLQ==",
 @etag="CN/7+oq4h9sCEAE=",
 @generation="1526377712893407",
 @id=
  "foo/uploads/profile/avatar/328/thumb_WeChat_Image_20180112102430.jpg/1526377712893407",
 @kind="storage#object",
 @md5_hash="CRdX68ncBsEqJFY/uRg03A==",
 @media_link=
  "https://www.googleapis.com/download/storage/v1/b/deanslist-9322/o/uploads%2Fprofile%2Favatar%2F328%2Fthumb_WeChat_Image_20180112102430.jpg?generation=1526377712893407&alt=media",
 @metageneration="1",
 @name="uploads/profile/avatar/328/thumb_WeChat_Image_20180112102430.jpg",
 @self_link=
  "https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2Fthumb_WeChat_Image_20180112102430.jpg",
 @size="5923",
 @storage_class="NEARLINE",
 @time_created=Tue, 15 May 2018 09:48:32 +0000,
 @time_storage_class_updated=Tue, 15 May 2018 09:48:32 +0000,
 @updated=Tue, 15 May 2018 09:48:32 +0000>

Sending HTTP get https://www.googleapis.com/storage/v1/b/foo?
200
#<Hurley::Response GET https://www.googleapis.com/storage/v1/b/foo == 200 (374 bytes) 59ms>
Success - #<Google::Apis::StorageV1::Bucket:0x007f98b3252328
 @etag="CAI=",
 @id="foo",
 @kind="storage#bucket",
 @location="ASIA-SOUTHEAST1",
 @metageneration="2",
 @name="foo",
 @project_number="1028403006209",
 @self_link="https://www.googleapis.com/storage/v1/b/foo",
 @storage_class="NEARLINE",
 @time_created=Wed, 20 Dec 2017 05:50:41 +0000,
 @updated=Wed, 20 Dec 2017 07:08:46 +0000>

Sending HTTP get https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2Ftestimonial_WeChat_Image_20180112102430.jpg?
200
#<Hurley::Response GET https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2Ftestimonial_WeChat_Image_20180112102430.jpg == 200 (974 bytes) 59ms>
Success - #<Google::Apis::StorageV1::Object:0x007f98b6a82a40
 @bucket="foo",
 @content_type="image/jpeg",
 @crc32c="VFIp7Q==",
 @etag="CJbO2Yu4h9sCEAE=",
 @generation="1526377714444054",
 @id=
  "foo/uploads/profile/avatar/328/testimonial_WeChat_Image_20180112102430.jpg/1526377714444054",
 @kind="storage#object",
 @md5_hash="QGE8XArsE5C9QD2A6ybpVg==",
 @media_link=
  "https://www.googleapis.com/download/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2Ftestimonial_WeChat_Image_20180112102430.jpg?generation=1526377714444054&alt=media",
 @metageneration="1",
 @name=
  "uploads/profile/avatar/328/testimonial_WeChat_Image_20180112102430.jpg",
 @self_link=
  "https://www.googleapis.com/storage/v1/b/foo/o/uploads%2Fprofile%2Favatar%2F328%2Ftestimonial_WeChat_Image_20180112102430.jpg",
 @size="2481",
 @storage_class="NEARLINE",
 @time_created=Tue, 15 May 2018 09:48:34 +0000,
 @time_storage_class_updated=Tue, 15 May 2018 09:48:34 +0000,
 @updated=Tue, 15 May 2018 09:48:34 +0000>