Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 回形针未上传到Bucket,未返回错误_Ruby On Rails_Amazon S3_Paperclip - Fatal编程技术网

Ruby on rails 回形针未上传到Bucket,未返回错误

Ruby on rails 回形针未上传到Bucket,未返回错误,ruby-on-rails,amazon-s3,paperclip,Ruby On Rails,Amazon S3,Paperclip,我已经和这件事斗争了一段时间了。我正在使用回形针和AWS-SDK。我已配置了存储桶和帐户。已授予权限。表单数据(包括回形针模型值)都保存到我的Sqlite3表中。但是,该图像不会上载到S3上的my bucket。我没有收到任何错误。对这里可能出现的问题有什么建议吗 提前谢谢 这是附件控件,它在我的表单中。表单路由到我的动物控制器上的Create方法 开发配置(我已验证我处于开发模式) Animal/new.html.erb Animal.rb 所以我想出来了,我想我应该发布解决方案,这样我可以得

我已经和这件事斗争了一段时间了。我正在使用回形针和AWS-SDK。我已配置了存储桶和帐户。已授予权限。表单数据(包括回形针模型值)都保存到我的Sqlite3表中。但是,该图像不会上载到S3上的my bucket。我没有收到任何错误。对这里可能出现的问题有什么建议吗

提前谢谢

这是附件控件,它在我的表单中。表单路由到我的动物控制器上的Create方法

开发配置(我已验证我处于开发模式) Animal/new.html.erb Animal.rb
所以我想出来了,我想我应该发布解决方案,这样我可以得到更多的反对票。尽管我在这里看到过无数有类似问题的回形针帖子,但他们都获得了多张赞成票

从我的config/environments/development文件中删除凭据并将所有配置放在我的模型中似乎可以做到这一点。此外,我的样式字段中有一个哈希符号

  has_attached_file :animal_image,
                    :style => {:medium => "300x300>", :thumb => "100x100>"},
                    :storage => :s3,
                    :bucket  => "my bucket",
                    :s3_credentials => {
                        :bucket  => "my bucket",
                        :access_key_id => ENV["My key"],
                        :secret_access_key => ENV["My Secret"]
                    },
                    :s3_permissions => "private",
                    :url => ":s3_domain_url"
                    Paperclip::Attachment.default_options[:url] = ":s3_domain_url"
                    Paperclip::Attachment.default_options[:path] = "/:class/:attachment/:id_partition/:style/:filename"

这真的是a-1吗?
   <div class="form-group padding-top-bottom-10">
      <%= f.file_field :animal_image %>
      <label class="label label-warning">Attach Your Photo</label>
      <div class="row padding-top-bottom-10"></div>
   </div>
 def create

@animal = Animal.new(animal_params)
respond_to do |format|
    if @animal.save
      flash[:notice] = "#{@animal.full_name} has been added to your profile."
      format.json { render json: @animal, status: :created, location: @animal }
      format.html { render "animal/index" }
    else
      flash.now[:error] = @animal.errors.full_messages
      format.html { render action: "new" }
      format.json { render json: @animal.errors, status: :unprocessable_entity }
    end
  end
end

private
def animal_params

params.require(:animal).permit(:full_name, :profile_id, :age, :gender, :purr_factor,           :weight, :height,
                                            :length, :fixed, :shots, :papers, :animal_desc, :breed_id, :animal_image)
end
        :animal_image_content_type
        :animal_image_file_name

        has_attached_file :animal_image, style: {
         thumb: '100x100>',
         square: '200x200#',
         medium: '300x300>'
        }

        # Validate the attached image is image/jpg, image/png, etc
       validates_attachment_content_type :animal_image, :content_type => /\Aimage\/.*\Z/
  has_attached_file :animal_image,
                    :style => {:medium => "300x300>", :thumb => "100x100>"},
                    :storage => :s3,
                    :bucket  => "my bucket",
                    :s3_credentials => {
                        :bucket  => "my bucket",
                        :access_key_id => ENV["My key"],
                        :secret_access_key => ENV["My Secret"]
                    },
                    :s3_permissions => "private",
                    :url => ":s3_domain_url"
                    Paperclip::Attachment.default_options[:url] = ":s3_domain_url"
                    Paperclip::Attachment.default_options[:path] = "/:class/:attachment/:id_partition/:style/:filename"