直接上传后直接将URL分配给has_attachment

问题描述 投票:0回答:0

我能够生成一个预签名 URL,以便从 iOS 应用程序直接上传。我想根据这个预先指定的 URL 直接设置 ActiveStorage 附件 URL。这样,rails 就不会处理上传数据。我似乎找不到一个规范的方法来解决这个问题。我尝试直接设置

key
,但这是附件 blob 的属性。

    @photo = @field_note.photos.new(key: "field_notes/#{@field_note.uuid}/photos/#{photo_params[:filename]}")
    @presigned_url = AwsBucketAccessor.bucket.presigned_post(
      key: @photo.key,
      success_action_status: "201",
      signature_expiration: (Time.now.utc + 15.minutes)
    )
    render(:show) && return if @photo.save
rails-activestorage
© www.soinside.com 2019 - 2024. All rights reserved.