1

I am using the FileStack API and filepicker gem. According to the documentation (http://www.rubydoc.info/github/Ink/filepicker-rails/master/FilepickerRails/ApplicationHelper:filepicker_save_button) the save button takes an options hash. However, when I implement it, none of the options work i.e. save_as_name nor services work.

<%= filepicker_save_link "Save", a.title, "pdf", save_as_name: "exampleName", services: 'BOX' %>

Am I implementing this wrong? Or is it a problem with the gem?

user3318660
  • 303
  • 1
  • 3
  • 17

1 Answers1

0

It was a problem with the gem itself. Contacted a FileStack engineer and this is what he suggested and now it works. Just add to the controller helper that you're working with. They will notify the engineer who maintains the gem of this issue.

def export_widget(text, url, mimetype, options, &block)
   options[:data] ||= {}
   container = options.delete(:container)
   services = options.delete(:services)
   save_as = options.delete(:save_as_name)

   options[:data]['fp-url'] = url
   options[:data]['fp-apikey'] =  ::Rails.application.config.filepicker_rails.api_key
   options[:data]['fp-mimetype'] = mimetype
   options[:data]['fp-option-container'] = container if container
   options[:data]['fp-option-services'] = Array(services).join(",")     if services
   options[:data]['fp-option-defaultSaveasName'] = save_as if save_as
   block.call
  end
 end
end

From engineer: "So maybe you can make it work by editing the application helper where it has fp-option-services, change it to fp-services for example, like this :

options[:data]['fp-services'] = Array(services).join(",") if services

The options need to be passed as a Ruby hash. For example, when utilizing this

<%= filepicker_save_link "Save", a.title, "application/pdf", { save_as_name: "exampleName", services: 'BOX'} %>
user3318660
  • 303
  • 1
  • 3
  • 17