访问属性的权限被拒绝'filepicker_comm_iframe'

Permission denied to access property 'filepicker_comm_iframe'

本文关键字:属性 comm iframe filepicker 拒绝 访问 权限      更新时间:2023-12-16

当前在我的应用程序中遇到Filepicker的iframe问题。。。我的工具:

  • 框架:Rails 4(包括涡轮连杆)
  • API:文件选取器.io(JS)
  • 文件类型:Coffeescapet

我的样本代码:

ready = ->
filepicker_api_key = $js_data.data('filepickerApiKey')
unprocessed_path = $js_data.data('unprocessedPath')
filepicker.setKey(filepicker_api_key)
  $('#image-upload').click (e) ->
    picker_options =
    services: ['COMPUTER']
    mimetypes: ['image/*']
    store_options =
    location: 's3'
    path: unprocessed_path
    access: 'public'
    filepicker.pickAndStore picker_options, store_options ->
      console.log 'foobar'
      # alot of code comes here.. which works whenever I refresh the page
$(document).ready(ready)
$(document).on('page:load', ready)

一旦我尝试上传内容,它就会停止。我的日志显示此错误:

错误:访问属性的权限被拒绝'filepicker_comm_iframe'

并且不显示我的'foobar'日志

但是当我刷新页面时,我没有收到任何错误,并且文件相应地上传。我正在努力避免不得不刷新页面以成功上载。

由于涡轮连杆的机身是重新加载的,我建议在布局文件中移动此代码:

<%= filepicker_js_include_tag %>

从CCD_ 2到CCD_。

它应该可以正常工作(在Rails4中,不需要安装"jquery-turboxlinks"gem)。在未来,我们将研究通用解决方案,独立于此标签的放置位置。

我通过将gem 'jquery-turbolinks'添加到我的Gemfile(从而运行捆绑包)并将//= jquery.turbolinks包含到我的application.js中,解决了这个问题。

到目前为止,这是我遇到的唯一有价值的工作。对于这个特定的场景。

加载后,filepicker js将2个iframe添加到body中。当你使用涡轮链接来改变页面时,它们就不见了。所以你需要自己再次添加它们:

    if $("#filepicker_comm_iframe").length == 0
      $("body").append '<iframe name="filepicker_comm_iframe" id="filepicker_comm_iframe" src="https://dialog.filepicker.io/dialog/comm_iframe/" style="display: none;"></iframe>'
    if $("#fpapi_comm_iframe").length == 0
      $("body").append '<iframe name="fpapi_comm_iframe" id="fpapi_comm_iframe" src="https://www.filepicker.io/dialog/comm_iframe/" style="display: none;"></iframe>'