Giter Club home page Giter Club logo

rails-sdk's People

Contributors

avokhmin avatar einzige avatar felixge avatar ifedapoolarewaju avatar juliangruber avatar kiloreux avatar kvz avatar levent avatar matthiasjakel avatar nqst avatar olleolleolle avatar rmehner avatar samullen avatar scudco avatar stouset avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rails-sdk's Issues

undefined method `transloadit'

Going from the example in the README:

<%= form_tag 'http://api2.transloadit.com/assemblies', :html => { :id => 'upload' } do |form| %>
  <%= transloadit :s3_store %>
  <%= form.label      :file, 'File to upload' %>
  <%= form.file_field :file %>
  <%= form.submit %>
<% end %>
<%= transloadit_jquerify :upload %>

I get undefined method 'transloadit' for #<#<Class:0x000000011aadc8>:0x00000005ebd840>.

notify_url usage

on Rails 3.2.8
Im trying to use notify_url

#config/transloadit.yml
auth:
  key     : ...
  secret  : ...
  duration: 1800 # 30 minute validity period for signed upload forms

notify_url: http://...../callback

templates:
  image_video: ...

But, the output generated by <%= transloadit :image_video %> doesn't include notify_url param

Sorry, it was just an undocumented use case, in the view:

<%= transloadit :image_video, :notify_url=>'http://someurl' %>

works

Lazy config loading

Users should be able to edit their transloadit config without having to restart the server during development.

Hashify JSON response

Transloadit returns a JSON response that should be converted to a Rails-style HashWithIndifferentAccess automatically. Figure out how to do this, and do it.

Switch to GitHub Actions

Since Travis isn't usable for open source anymore.

When we are done, we should also update the badge at https://transloadit.com/docs/#sdks by adding this frontmatter to the rails-sdk integration file:

ghactions_workflow: Rails SDK CI # assuming that becomes the github actions workflow name

max_size doesn't seem to work.

I tried putting max_size in the transloadit.yml file like this:

auth:
  key     : '418...'
  secret  : '660...'
  duration: 1800 # 30 minute validity period for signed upload forms
  max_size: 2097152

templates: ...

I can't get it to work. According to the Authentication page in the docs

You need to use max_size in the hidden params field of your form.

I've tried adding a hidden field in the form named "max_size" but it doesn't work either.

Is there a way to set a maximum file size?

Publish new gem version

Hi,

I just merged #10 from my friend Robin who is using the gem for a very big project. His changes made sense to me so I went ahead, but please feel free to comment.

If things look reasonable, could you please publish a new version of the gem? If there is a way to make it possible for me to do that as well, that'd be great.

--fg

Deprecation warning in Rails 3.2

Using this gem with Rails 3.2 results in:

DEPRECATION WARNING: ActiveSupport::Memoizable is deprecated and will be removed in future 
releases, simply use Ruby memoization pattern instead. (called from <top (required)>
 at .../config/application.rb:11)

it looks like it should be simple to replace the memoize :configuration call with a bit of @configuration cachery.

Problem with transloadit_jquerify when trying to define callbacks.

Hi,

I tried to call transloadit_jquerify method while defining onError and onCancel callbacks, like this:

<%= transloadit_jquerify :video_form, wait: false, processZeroFiles: false,
  onCancel: "function() { console.log('Entered on cancel'); }",
  onError: "function() { console.log('Entered on error'); }" %>

but it did not work. The generated script was like this:

<script type="text/javascript">
//<![CDATA[

      jQuery(function($) {
        var script = '//assets.transloadit.com/js/jquery.transloadit2-latest.js';

        $.getScript(script, function() {
          $('#video_form')
            .attr('enctype', 'multipart/form-data')
            .transloadit({"wait": false,
"processZeroFiles": false,
"onCancel": function() {console.log('Entered on cancel'); },
"onError": function() { console.log('Entered on error'); }});
        });
      });

//]]>
</script>

I figured out that the problem's with the "onCancel" and "onError" being strings. When I wrote the generated script manually and removed the double quotes it all worked well.

Also there's not much documentation regarding how to use callback functions with transloadit_jquerify. I had to take a look at the code to see how you guys expect callbacks to be provided.

Dynamic fields not working in template

I'm trying to update my transloadit templates to use some more dynamic fields from the html form (Rails, Rackspace cloud files, transloadit_jquerify etc), however the fields object doesn't seem to contain the values I'm passing.

The template is set up like this:

store:
          use: ['optimized']
          robot: '/cloudfiles/store'
          container: *rs_container
          user: *rs_user
          key: *rs_key
          data_center: *rs_data_center
          account_type: *rs_account_type
          path: "images/${fields.item_category}/${file.id}_${file.url_name}"

and my HTML form contains the following:

<%= form_for item, :url => form_url, :html => { :id => 'upload_image' } do |form| %>
  <%= transloadit :image_upload %>
  <%= form.label :file, 'File to upload' %>
  <%= form.file_field :file, :accept => "image/jpg, image/jpeg, image/png" %>
  <%= form.label :name, "Description" %>
  <input type="text" name="name" id="name"/>

  <!-- I have tried both options for creating a hidden field -->
  <%= form.hidden_field 'item_category', :value => item_category %>
  <input type="hidden" name="item_category" id="item_category" value="<%= item_category %>" />

  <%= form.submit 'Upload Image', :id => "submitBtnImage" %>
<% end %>

<%= transloadit_jquerify :upload_image, :wait => true, :processZeroFiles => false %>

But the item_category is always empty or nil, resulting in a file path like images//XXX_file.jpg

Any ideas what I'm doing wrong here?

Options not working because to_json makes everything a string

In Issue #3 you state you can pass arguments correctly. However, if I want to add a callback function such as :onResult => "my_function() { alert('do stuff') }", the resulting javascript ends up looking like:

"onResult": "my_function() { alert('do stuff') }"

onResult() is a string (rather than a function) and thus, not actually executed. It seems this happens because you parse the options using to_json, which would convert any Javascript code into a string rather than pass it straight through. Am I missing something here? Is there a better way to do this using your gem?

Ability to vary expiration time on forms

Currently these helpers result in a form that is valid for 5 minutes. Thats quite rough.

Case: User comes to form. Spends 10 minutes on finding 5 photos to upload. Hits upload -> suddenly the upload is invalid because form was valid only 5 minutes.

I'd need the follow to work:

<%= transloadit :upload_basics, {:auth => [:expires => 1.hour.from_now]} %>

Easiest would be to change view_helper to change the hash auth params before signing it. More clearlier fix would be to change how ruby-sdk work and change this one accordingly.

Cant convert a video to mp4 and keep its size

I am trying get a video out as a mp4 and I need to keep the original proportions.

This is my current Template

{
  "steps": {
    "encode": {
      "use": ":original",
      "robot": "/video/encode",
      "ffmpeg_stack": "v2.2.3",
      "result": true,
      "preset": "ipad-high",
      "ffmpeg_params": {
        "s": "-1x-1"
      }
    },
    "thumbnails": {
      "use": ":original",
      "robot": "/video/thumbs"
    },
    "store": {
      "use": "encode",
      "robot": "/s3/store",
      "key": "xxxxxxxxxxx",
      "secret": "xxxxxxxxxxx",
      "bucket": "xxxxxxxxxxx"
    }
  }
}

/file/filter robot

Hi,

I've been trying to make the /file/filter robot work with my rails app and failing.
I haven't found any useful ruby on rails examples in the Transloadit docs.
I would like some help on how to use the /file/filter robot to decline a file larger than 10MB using ruby on rails.

Thank you

uninitialized constant Transloadit::Rails::ViewHelper

Hello,

I am using Rails 3.1

transloadit-rails gem version 1.0.2

I tried to use the transloadit-rails gem by following the tutorial for rails-sdk. Can anyone help me?

This is the error log

[2011-10-19 15:47:06] ERROR NameError: uninitialized constant Transloadit::Rails::ViewHelper
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/transloadit-rails-1.0.0/lib/transloadit/rails/engine.rb:21:in `block (2 levels) in <class:Engine>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_view/base.rb:216:in `<class:Base>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_view/base.rb:133:in `<module:ActionView>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_view/base.rb:8:in `<top (required)>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/abstract_controller/view_paths.rb:90:in `view_paths='
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/abstract_controller/view_paths.rb:76:in `prepend_view_path'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/engine.rb:532:in `block (2 levels) in <class:Engine>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `each'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.1/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_controller/base.rb:234:in `<class:Base>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_controller/base.rb:171:in `<module:ActionController>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_controller/base.rb:3:in `<top (required)>'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_dispatch/middleware/static.rb:31:in `ext'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_dispatch/middleware/static.rb:15:in `match?'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/actionpack-3.1.1/lib/action_dispatch/middleware/static.rb:47:in `call'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/engine.rb:456:in `call'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/rack/content_length.rb:16:in `call'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.1.1/lib/rails/rack/log_tailer.rb:14:in `call'
    /Users/weyewe/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.3.5/lib/rack/handler/webrick.rb:59:in `service'
    /Users/weyewe/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:111:in `service'
    /Users/weyewe/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run'
    /Users/weyewe/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

alert: "Could not find input[name=params] in your form" on submission

I followed the tutorial but can't get the form to submit without getting the aforementioned alert. After I click "ok", Transloadit quickly throws INVALID_FORM_DATA: bad form data, cannot parse.

My app is using Rails 4.1.4 and jquery-rails 2.1.4.

Here's my form:

= form_for @profile, url: community_add_photo_path(@profile), html: {id: 'photo_form'} do |f|
  = render 'shared/error_messages', object: f.object
  = transloadit :profile_photo
  = hidden_field_tag 'transloadit_template', 'profile_photo'

  %table.list
    %tr
      %td.faded.label Photo Filename
      %td= f.file_field :photo, required: true
    %tr
      %td
      %td= f.submit 'Upload'

= transloadit_jquerify :photo_form, wait: true

And my transloadit.yml file:

development:
  jquery_sdk_version: 'latest'
  auth:
    key:      'key'
    secret:   'secret'
    duration: 1800 # 30 minute validity period for signed upload forms

  templates:
    profile_photo:
      steps:
        resize:
          height: 256
          resize_strategy: 'fillcrop'
          robot: '/image/resize'
          width: 256
        store:
          bucket: 'bucket-name'
          key: 'key'
          path: 'temp/${assembly.id}/${file.name}'
          robot: '/s3/store'
          secret: 'secret'

Any suggestions? Thanks!

Better error message when config loading fails

Something went wrong when loading my config, and I got:

NoMethodError in Uploads#index

Showing /Users/felix/Desktop/transloadit-test/app/views/uploads/index.html.erb where line #2 raised:

You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[]

Extracted source (around line #2):

1: <%= form_for :thing, :html => { :id => 'upload' } do |form| %>
2:   <%= form.transloadit :my_template %>
3:   <%= form.file_field :file, 'File to upload' %>
4: <% end %>
5: 

Rails.root: /Users/felix/Desktop/transloadit-test

Turning this into a more helpful message would be great.

Integrate with Paperclip

Paperclip is pretty ubiquitous. It'd be nice to integrate support with it. There will likely be multiple use-cases:

  1. Upload to S3 with transloadit
    a. needs to extend paperclip with a transloadit_id in the path
    b. needs to add migrations for transloadit_id
  2. Retrieve upload from transloadit, upload to S3 in paperclip

Helpers javascript/jquery output fails with other libraries

rails-sdk / app / helpers / transloadit_helper.rb file needs fixes. (https://github.com/transloadit/rails-sdk/blob/master/app/helpers/transloadit_helper.rb)

Dollar sign is also used by other libraries, so you can't trust that its reserved for jquery: http://docs.jquery.com/Plugins/Authoring

(Yeah, I'm slowly migrating from prototype to jquery)

transloadit_helper.rb produces following:

$(function() {
CODE INSIDE HERE
});

It should be:

(function($) {
CODE INSIDE HERE
}(jQuery));

So the total helper would be:

def transloadit_jquerify(id, options = {})
    javascript_tag %{
      (function($) {
      var script = '//assets.transloadit.com/js/jquery.transloadit2.js';
      $.getScript(script, function() {
      $('##(id)')
      .attr('enctype', 'multipart/form-data')
      .transloadit({wait: true, fields: true});
      });
      }(jQuery));
    }
end

Not working with latest jquery-rails gem

transloadit-rails works great for me using jquery-rails 2.1.3 (which uses JQuery 1.8.2). But it doesn't work with jquery-rails 2.2.1 (JQuery 1.9.1). The symptom is that the form submit doesn't seem to get intercepted anymore - the form gets posted straight to my server.

Let me know if this is jquery-sdk's fault and I'll move this issue over.

Rails-sdk compatible with rails 2.3

My app is using ruby 1.8.7 and rails 2.3.5. Does the current version of rails-sdk support rails 2.3? If it is not, could you give me a link of older version which compatible with rails 2.3?

example response for an Assembly

A user playing around with the rails example had this to say

The Rails example you have does not include any information about how to save the uploaded file information to the database for later usage. I can see the information can be taken from some params, but to me the documentation seems very confusing there - params[:transloadit][:results][:resize].first[:url] - how does this adapt to different Transloadit templates? How can I get the information on the form itself before submitting it?

A good way to solve this may be to have the example display a formatted JSON tree of the assembly response.

Add full example

From installing rails to uploading and resizing an image and displaying the results.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.