Skip to content

Instantly share code, notes, and snippets.

@jeena
Created November 23, 2012 19:52
Show Gist options
  • Save jeena/4137022 to your computer and use it in GitHub Desktop.
Save jeena/4137022 to your computer and use it in GitHub Desktop.
Posting a post with an attachment fails on tentd
# /Users/jeena/Sites/tentd/lib/tentd/api/posts.rb:124
def authorize_post!(env)
puts env.params.inspect
# ...
end
# => #<Hashie::Mash attachments=[]>
#<NoMethodError: undefined method `entity=' for nil:NilClass>
/Users/jeena/Sites/tentd/lib/tentd/api/posts.rb:143:in `authorize_post!'
/Users/jeena/Sites/tentd/lib/tentd/api/posts.rb:97:in `action'
/Users/jeena/Sites/tentd/lib/tentd/api/middleware.rb:15:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/middleware.rb:16:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/router/extract_params.rb:15:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/middleware.rb:16:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/middleware.rb:16:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/middleware.rb:16:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/middleware.rb:16:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/router/cors_headers.rb:10:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/etag.rb:23:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/router/etag_check.rb:10:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/head.rb:9:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-mount-0.8.3/lib/rack/mount/prefix.rb:26:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:152:in `block in call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:96:in `block in recognize'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:75:in `optimized_each'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-mount-0.8.3/lib/rack/mount/code_generation.rb:95:in `recognize'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-mount-0.8.3/lib/rack/mount/route_set.rb:141:in `call'
/Users/jeena/Sites/tentd/lib/tentd/api/router.rb:38:in `call'
/Users/jeena/Sites/tentd-admin/lib/tentd-admin/set_entity.rb:8:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/builder.rb:134:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/urlmap.rb:64:in `block in call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `each'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/urlmap.rb:49:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/commonlogger.rb:20:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.3/lib/sinatra/base.rb:136:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/puma-1.6.3/lib/puma/server.rb:412:in `handle_request'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/puma-1.6.3/lib/puma/server.rb:306:in `process_client'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/puma-1.6.3/lib/puma/server.rb:215:in `block in run'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/puma-1.6.3/lib/puma/thread_pool.rb:94:in `call'
/Users/jeena/.rvm/gems/ruby-1.9.3-p125/gems/puma-1.6.3/lib/puma/thread_pool.rb:94:in `block in spawn_thread'
83.233.171.64 - - [23/Nov/2012 20:29:31] "POST /posts HTTP/1.1" 500 - 0.0334
POST /posts HTTP/1.1
Host: lala.home.jeena.net:3002
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko)
Content-Length: 222981
Accept: undefined
Origin: file://
Authorization: MAC id="u:12345659", ts="1353705288", nonce="zC4yS8RZ", mac="123456dqXSXDQPCdELL3nO0s1on1l9AGcwT8Av123456"
Content-Type: multipart/form-data;boundary=-----------TentAttachment
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: keep-alive
-----------TentAttachment
Content-Disposition: form-data; name="post"; filename="post.json"
Content-Length: 135
Content-Type: application/vnd.tent.v0+json
Content-Transfer-Encoding: binary
{"type":"https://tent.io/types/post/photo/v0.1.0","published_at":1353705287,"permissions":{"public":true},"content":{"caption":"test"}}
-----------TentAttachment
Content-Disposition: form-data; name="photos[0]"; filename="photo.png"
Content-Length: 166857
Content-Type: image/png
Content-Transfer-Encoding: binary
iVBORw0KGgoAAAANSUhEUgAAA... base64-representation of a png image
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment