Re: Uploading a file - undefined method `bytesize' for true:TrueClass

132 views
Skip to first unread message

Hans Hasselberg

unread,
Jun 8, 2013, 6:32:43 PM6/8/13
to typh...@googlegroups.com
Hey Glenn,

could you open an issue on github with code to reproduce b/c I'm not able to. Please also mention which version of Typhoeus you are running.

Thanks.


On Tue, Jun 4, 2013 at 11:31 PM, Glenn Daneels <glennd...@gmail.com> wrote:
Hi all,

I'm trying to upload a file and some other data using following code:

                                response = Typhoeus::Request.new(
                                "#{@server}/api/templates/",
                                {       :method => :post,
                                        :headers => { "Authorization" => "Token #{@token}", :accept => "application/json" },
                                        :body => {      :image_uri => File.new("#{template["local_uri"]}", 'rb'),
                                                        :name => template["name"],
                                                        :description => template["description"],
                                                        :type => template["type"],
                                                        :node_archs => template["node_archs"],
                                                        :is_active => true
                                                 },
                                }
                                ).run

But I keep getting following error: "undefined method `bytesize' for true:TrueClass"

I also tried it with :image_uri => File.open("#{template["local_uri"]}", 'rb') but this had the same result...
The variable template["local_uri"] is equal to "/home/glenn/omf-openwrt-testing-rootfs-latest.tar.gz"

I'm using Ruby 1.8.7.

Do I need to add/change something (some headers or something)? 
Could someone please help me along?

Thanks in advance,
Glenn

--
You received this message because you are subscribed to the Google Groups "Typhoeus" group.
To unsubscribe from this group and stop receiving emails from it, send an email to typhoeus+u...@googlegroups.com.
To post to this group, send email to typh...@googlegroups.com.
Visit this group at http://groups.google.com/group/typhoeus?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Reply all
Reply to author
Forward
0 new messages