Quantcast

Uploading multiple files

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Uploading multiple files

Tomas Herman
Hey there,
i'm trying to upload multiple 'files' with dispatch, but i'm having some troubles. Could you please tell me what am i doing wrong?

This is the code i'm trying to run, although i tried like 30 different combinations of operators so i'm not sure if it even makes sense anymore :)

val file: File = ...
server <<* (file.getName,file) << ("data","data.json",() => new java.io.ByteArrayInputStream(req.toJson.toString.getBytes), "application/json")

As you can see, i'm trying to send a file first, followed by content of string, but this won't compile. It says:
overloaded method value << with alternatives:
[error]   (stringbody: String,contenttype: String)dispatch.Request <and>
[error]   (stringbody: String)dispatch.Request <and>
[error]   (values: Traversable[(String, String)])dispatch.Request
[error]  cannot be applied to (java.lang.String, java.lang.String, () => java.io.ByteArrayInputStream, java.lang.String)
[error]     val post = c.constants.api.upload <<* (file.getName,file) << ("data","data.json",() => new java.io.ByteArrayInputStream(req.toJson.toString.getBytes), "application/json")
[error]                                                               ^
[error] one error found


I imported both dispatch.mime._ and dispatach.mime.Mime._, i use 0.8.5 version of dispatch. Many thanks for any answer!

Tomas
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Uploading multiple files

n8han
Administrator
Hi Tomas, the Dispatch listserv is over here now:
https://groups.google.com/forum/?hl=en#!forum/dispatch-scala

On 02/04/2012 06:32 PM, Tomas Herman [via Databinder] wrote:
Hey there,
i'm trying to upload multiple 'files' with dispatch, but i'm having some troubles. Could you please tell me what am i doing wrong?

This is the code i'm trying to run, although i tried like 30 different combinations of operators so i'm not sure if it even makes sense anymore :)

val file: File = ...
server <<* (file.getName,file) << ("data","data.json",() => new java.io.ByteArrayInputStream(req.toJson.toString.getBytes), "application/json")

As you can see, i'm trying to send a file first, followed by content of string, but this won't compile. It says:
overloaded method value << with alternatives:
[error]   (stringbody: String,contenttype: String)dispatch.Request <and>
[error]   (stringbody: String)dispatch.Request <and>
[error]   (values: Traversable[(String, String)])dispatch.Request
[error]  cannot be applied to (java.lang.String, java.lang.String, () => java.io.ByteArrayInputStream, java.lang.String)
[error]     val post = c.constants.api.upload <<* (file.getName,file) << ("data","data.json",() => new java.io.ByteArrayInputStream(req.toJson.toString.getBytes), "application/json")
[error]                                                               ^
[error] one error found


I imported both dispatch.mime._ and dispatach.mime.Mime._, i use 0.8.5 version of dispatch. Many thanks for any answer!

Tomas



If you reply to this email, your message will be added to the discussion below:
http://databinder.3617998.n2.nabble.com/Uploading-multiple-files-tp7255058p7255058.html
To start a new topic under Databinder, email [hidden email]
To unsubscribe from Databinder, click here.
NAML

Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Uploading multiple files

Tomas Herman
Ooops, sorry :)
Loading...