# Upload file attachment with rest or xml

**URL:** <https://www.ruby-forum.com/t/upload-file-attachment-with-rest-or-xml/194363>\
**Category:** Rails\
**Created:** [September 3, 2010, 2:52am UTC](https://www.ruby-forum.com/t/upload-file-attachment-with-rest-or-xml/194363 "2010-09-03T02:52:56Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rorra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df788c/32.png) [@rorra](https://www.ruby-forum.com/u/rorra)\
**Post date:** [September 3, 2010, 2:52am UTC](https://www.ruby-forum.com/t/upload-file-attachment-with-rest-or-xml/194363/1 "2010-09-03T02:52:56Z")

</div>

I’ve a “attachment” model that has:

title: string  
image: paperclip attribute  
video: paperclip attribute

I want to let the users to upload an attachment by using xml or  
something like that, all the actions supports xml

If they call the controller/action ([http://example.net/attachments](http://example.net/attachments)) with  
a post, right now they could do something like

curl -H “Content-Type: application/xml” -X POST -d  
“Nice Picture”  
[http://example.net/attachments](http://example.net/attachments)

But I would like to get a way to test that if I upload the file by using  
curl or anything else, they will be able to upload the file, if they  
give it the param “image” it will be processed as an image, if they give  
it the param “video” it will be processed as a video

But I don’t have idea how they may call the action with the xml and  
upload the file, or if I should use another way or what

Thx

---

<div class="post-metadata">

**Author:** ![rorra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df788c/32.png) [@rorra](https://www.ruby-forum.com/u/rorra)\
**Post date:** [September 3, 2010, 7:50am UTC](https://www.ruby-forum.com/t/upload-file-attachment-with-rest-or-xml/194363/2 "2010-09-03T07:50:08Z")

</div>

Any help on this one?

---

<div class="post-metadata">

**Author:** ![rorra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df788c/32.png) [@rorra](https://www.ruby-forum.com/u/rorra)\
**Post date:** [September 3, 2010, 7:55am UTC](https://www.ruby-forum.com/t/upload-file-attachment-with-rest-or-xml/194363/3 "2010-09-03T07:55:32Z")

</div>

BTW, the code I had for the rails code is pretty simple

[http://pastie.org/1135382](http://pastie.org/1135382)

I’m just looking the way to upload a file by using a third party  
application (I’m trying to provide an api to customers)

Thank you

---

<div class="post-metadata">

**Author:** ![rorra](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/df788c/32.png) [@rorra](https://www.ruby-forum.com/u/rorra)\
**Post date:** [September 6, 2010, 4:39pm UTC](https://www.ruby-forum.com/t/upload-file-attachment-with-rest-or-xml/194363/4 "2010-09-06T16:39:42Z")

</div>

I’ll see if I can help. Can you explain what you want to see happen  
that’s not? What do the logs tell us? If you’re able to make this work  
in some situations, compare the log output to a failed request and see  
if the differences give us any clues.

Luke
