filestack-rails
filestack-rails copied to clipboard
Fixed the initialization of filestack client v3
filestack-js
v3's init
function expects two arguments: the api key and an object representing the eventual options (cname, ...). For instance:
const clientOptions = {
security: {
policy: "eyJleHBpcnkiOiAxNTQ2ODk5NDI4LCAiY2FsbCI6IFsicmVhZCIsICJzdGF0IiwgImNvbnZlcnQiLCAicGljayIsICJzdG9yZSJdfQ==",
signature: "1fed86599156df046f925e0f773866654a4fc209b0b85b173b5d8088e898b685"
},
cname: 'fs.mydomain.com'
}
const client = filestack.init(YOUR_API_KEY, clientOptions)
The current filestack_js_init_tag
helper can initialize a filestack client but the cname is not properly passed because the current code generates this:
var #{client_name} = filestack.init('#{apikey}', #{signature_and_policy}, '#{cname}');
The cname is passed as a third argument instead of being part of object passed as second argument. This used to work (at least with filestack-js v1) but in v3, it does not.
This patch uses the right init arguments when it runs with filestack-js v3.