Giter Club home page Giter Club logo

ruby-sdk's People

Contributors

acconut avatar aduh95 avatar felixge avatar gbuesing avatar ifedapoolarewaju avatar jasonaibrahim avatar juliangruber avatar kianmeng avatar krisselden avatar kvz avatar miry avatar nqst avatar pekeler avatar rmehner avatar samullen avatar stouset avatar tim-kos avatar timcraft 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ruby-sdk's Issues

The signature comes after the files in the POST request payload, which causes problems

In the POST payload to /assemblies, the signature should come right after the "params" field, and not after the files. There are various reasons:

  • It will create a NO_SIGNATURE_FIELD on the Assembly in some cases, which is a race condition that I will fix on our end.
  • The user should not need to wait for all of the files to upload to our server only to find out that she calculated the signature wrongly. On Transloadit's side we evaluate the signature as soon as it comes in and by that we could end the connection quickly if the signature is wrong.

Relevant code parts are:
https://github.com/transloadit/ruby-sdk/blob/master/lib/transloadit/assembly.rb#L60
https://github.com/transloadit/ruby-sdk/blob/master/lib/transloadit/request.rb#L77
https://github.com/transloadit/ruby-sdk/blob/master/lib/transloadit/request.rb#L129

I feel it's good design that the signature calculation code lives in the Request class and is added as an after thought. But I feel it might need to be moved to the assembly class and added before the files are added.

Use TravisCI for ruby-sdk

Hey there,

I've committed an initial TravisCI config (35e8dfc, db88647) to get rid of the manual multiruby-test thing we did in the past.

There are some things failing right now (have to figure out what happens there). Few notes / questions:

  • Do we really need 1.8.6 support? People should have moved to at least 1.8.7 anyway, best would be 1.9x of course.
  • The 1.8 support is hosed due to 9c082f1 by @samullen but as far as I can see, it's just the test which does not run, not the library itself. That affects Rubinius in 1.8 mode as well.
  • There seems to be a problem with rdiscount on 1.9.2, will have to check that out.
  • I had to specify the exact version of VCR to something < 2.0, as we have to migrate our casettes to work with 2.x and I didn't have the time right now :)

That's that, just wanted to let you know. If anywant wants to help, go for it :)

Unable to generate the right signature with ruby

Hi everyone,
First of all let me apologize, I know I'm not on the right channel here, but you are the only guys I found that can help me solve my problem.
I can't use this Gem because I do the main Transloadit code with Javascript on the front-end.
The only thing I have to deal on the server side with (Ruby 2.1.1 and Rails 4.1) is the signature generation, but I can't make it work.
I tried the example present in the documentation, with the code provided at https://transloadit.com/docs/api-docs#authentication-implementations.
It seems that you guys use the same code: https://github.com/transloadit/ruby-sdk/blob/master/lib/transloadit/request.rb#L199

p = JSON.generate({ auth: { expires: "2010/10/19 09:01:20+00:00", key: "2b0c45611f6440dfb64611e872ec3211"}, steps: { encode: { robot: "/video/encode" } } })
signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), "d805593620e689465d7da6b8caf2ac7384fdb7e9", p)

the result is 00320965b86d42b6d983d1fad3f126ee7385b962 but according to the documentation it should be 6032b7b62879829941b84df5cfaebfe4644ab4e3

Could you please tell me what I'm doing wrong ?

PS: I have also posted a stackoverflow question if you want to gain some karma ;)
http://stackoverflow.com/questions/24230394/transloadit-unable-to-generate-the-right-signature-with-ruby

Assembly List fails with Signature Error

Using a working Transloadit Ruby-SDK setup (processes video files correctly), I cannot seem to get the assembly.list or Transloadit.bill calls to work. I have "Deny requests that do not include a signature or a wrong one?" turned off on my account for now.

irb(main):001:0> assembly = Transloadit.assembly
=> {:auth=>{:key=>"MY_KEY_HERE", :expires=>"2018/05/19 01:24:57+00:00"}}
irb(main):002:0> assembly.list
=> {"error"=>"INVALID_SIGNATURE", "message"=>"The given signature does not match ours."}

I'm pretty sure it's because the signature is not being generated/sent but that's not made clear that it needs to be sent anywhere other than the transloadit docs.

Also, there's no documentation here on how to send a signature or if it's automatic.

Edit: Inspecting the request shows that it is indeed generating a signature, unclear why it's wrong.

Finally release this

Hi Steven,

I want to go ahead and finally release the ruby / rails sdks. I was just wondering if both have the latest source code published as a gem at this point / if not if you could go ahead and do that.

Cheers, Felix

Detect duplicate step names

Awesome library! One improvement came to mind. Since we're building steps as an array of objects, it would be nice for the library to detect if the user accidentally named two different steps with the same name, and raise an error. I just think that the way assemblies are built, this mistake can happen easily.

The current behaviour is probably that the latter step will silently override the previous, and I was just thinking that it would be great to explicitly let the user know that they made a mistake.

License?

Can you clearly describe what license this code is released under?

Binary data

It seems like the only way to send a file to Transloadit is with the open def. Our image, audio and video files are in the database as Base64 encoded binary files. Creating a temp file to upload is really a waste of resources when we already have a binary format. Any ideas how to solve it? Thanks

Setting audio of video

Hi,
I was looking for a code snippet that illustrates how to set the audio segment of a video. Do you have that?
Thanks very much!

NoMethodError: undefined method `body' for nil:NilClass

I am using transloadit gem version '1.0.4' on ruby ruby-1.9.3-p551.
I receive the error

NoMethodError: undefined method `body' for nil:NilClass
from /Users/aarram/.rvm/gems/ruby-1.9.3-p551@srma_api/gems/transloadit-1.0.4/lib/transloadit/response.rb:34:in `body'

when I do

require 'transloadit'

file_to_process = "https://dashboarddev.s3.amazonaws.com/e1/840430299911e786fee949b8f945fb/Penguins.png"

transloadit = Transloadit.new(
:key => KEY,
:secret => SECRET_KEY)

import = transloadit.step 'import', '/http/import',
{ :url => file_to_process}

resize_avatar = transloadit.step 'resize_avatar', '/image/resize',
{ :use => "import",
:background => "transparent",
:resize_strategy => "pad",
:width => 50,
:height => 50,
:format => "png" }

export = transloadit.step 'export', '/sftp/store',
{ :use => "resize_avatar",
:user => "sshacs",
:host => HOST,
:path => PATH,
:url_template => URL_TEMPLATE,
:ssl_url_template => SSL_URL_TEMPLATE,
:sshkey => SSH_KEY }

assembly = transloadit.assembly(
:steps => [ import, resize_avatar, export ]
)

response = assembly.submit!

Can you please help me? Currently I do not want to upgrade my ruby version.

JSON::ParseError when nginx returns 404

Sometimes the API returns a basic HTML 404 that the SDK tries to parse anyway, and I'm getting JSON::ParseError exception notifications from the following response:

<html>
  <head>
    <title>404 Not Found</title>
  </head>
    <body bgcolor="white">
      <center>
        <h1>404 Not Found</h1>
      </center>
      <hr>
      <center>nginx/1.7.1</center>
    </body>
</html>

Totally understand the API being unreachable every so often (this happened only twice in two minutes), but I did expect the SDK to catch the 404 response and raise it's own exception or return a response object.

Improve completed? semantics and error handling

Right now the response object is very confusing. If you wait for response.completed? to be true, it will never happen if there is an error. This is because completed? returns false even if the assembly failed to execute.

I suggest changing the methods to be something more like:

  • response.completed? - returns true if the assembly is done processing
  • response.success? - returns true if the assembly is done processing and succeeded (this is what completed? currently returns)
  • response.error? returns true if the assembly is done processing and had an error

Git tags are missing for recent versions

The latest git tag on GitHub is v1.1.0, so the following tags are missing:

  • v1.1.1
  • v1.1.2
  • v1.1.3
  • v1.1.4
  • v1.2.0
  • v2.0.0
  • v2.0.1

I would recommend using the Rake tasks provided by Bundler, which automate the process of building, releasing, tagging, and pushing:

# Rakefile
require "bundler/gem_tasks"
# ...
$ rake release # builds, releases, tags, and pushes the version specified in transloadit.gemspec

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 ruby-sdk integration file:

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

response['assembly_id'] works; response[:assembly_id] does not

After submitting an assembly, response['assembly_id'] returns the assembly id, but response[:assembly_id] just returns nil.

However, the README promises that response[:assembly_id] will work.

Looking at the code for Transloadit::Response, you're just doing JSON.parse on the body, which returns string keys, not symbol keys.

This could be easily fixed by adding a #to_s coercion in Transloadit::Response#[]:

def [](attribute)
  self.body[attribute.to_s]
end

Signature expiry should be configurable

A low timeout makes sense for direct API access, but not so much for the Rails SDK. The timeout should be configurable so the Rails SDK can override it with a higher default (and let the client override it if need be).

Add Response#reload_until_finished!

I'm creating assemblies in background jobs, and polling until they are finished so that I can save the results in the database. The README here shows a simple polling example, and notes "you'll want to implement a timeout in your production app" -- here's a helper I rolled up, with a simple max tries timeout threshold: https://gist.github.com/gbuesing/e2f0b94ae3d2f9b0c6848b82ace51201

Seems like this is a common enough pattern that it could be provided by this library, vs. everyone rolling their own. I think the api could look something like:

response = assembly.create!
response.reload_until_finished! max_tries: 300
results = response['results'] # i.e. can work with results now, or MaxTries exception was raised

I don't think Ruby's Timeout is worth pursuing here, after reading http://www.mikeperham.com/2015/05/08/timeout-rubys-most-dangerous-api/

Synchronous Processing does not complete for large files

As per documentation, to do synchronous processing

# loop until processing is finished
until response.finished?
  sleep 1; response.reload! # you'll want to implement a timeout in your production app
end

I use this code but it locks up the ruby thread indefinitely (even though Assembly has completed) only when i upload large files ~ 3GB
< 1 gb files works fine which makes this a very odd problem

Is there an internal timeout which is not caught?

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.