Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用出现Aliyun::OSS::ServerError #7

Closed
huzhijia opened this issue May 8, 2018 · 3 comments
Closed

使用出现Aliyun::OSS::ServerError #7

huzhijia opened this issue May 8, 2018 · 3 comments

Comments

@huzhijia
Copy link

huzhijia commented May 8, 2018

storate.yml

local:
  service: Aliyun
  access_key_id: "*******"
  access_key_secret: "******"
  bucket: "product"
  endpoint: "http:https://oss-cn-beijing.aliyuncs.com"
  # path prefix, default: /
  path: "/product"
  # Bucket mode: [public, private], default: public
  mode: "private"

model

class Product < ApplicationRecord

	belongs_to :category

	has_many :order_items

	has_one_attached :product_image #产品首图

	enum status:{
		'未发布': false,
		'已发布': true
	}
end

views

<%=f.file_field :product_image %>

controller.rb

  create方法代码
  @product = Product.new(product_params)
  @product.save

private
  def product_params
      params.require(:product).permit!
    end

出现一下oss服务问题:

Aliyun::OSS::ServerError (The specified object is not valid. RequestId: 5AF11498A645AE2A87914BD3):

app/controllers/admin/products_controller.rb:12:in `create'
@huacnlee
Copy link
Owner

huacnlee commented May 8, 2018

object 路径开头不能是 “/”

@huacnlee
Copy link
Owner

huacnlee commented May 8, 2018

path: "product"

@huacnlee
Copy link
Owner

huacnlee commented May 8, 2018

Fixed in 0.4.1

@huacnlee huacnlee closed this as completed May 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants