+postMultiPartExample :: String -> [File] -> <Proc, Exception> String
+postMultiPartExample uri files = do
+ httpClient = buildClient clientBuilder
+ webTarget = target httpClient uri
+ builder = request webTarget
+ acceptMediaType builder [WILDCARD_TYPE]
+ mp = formDataMultiPart
+ addBodyPart mp $ formDataBodyPart "Name" "Test" $ withCharset TEXT_PLAIN_TYPE "utf-8"
+ iterI (\i f ->
+ addBodyPart mp $ fileDataBodyPart ("file" + show i) f APPLICATION_OCTET_STREAM_TYPE
+ ) files
+ invocation = buildPost builder $ entity mp MULTIPART_FORM_DATA_TYPE
+ response = syncInvoke invocation
+ print $ statusCodeOf response
+ print $ statusMessageOf response
+ res = readEntity response
+ close httpClient
+ res
+
+postFileExample :: String -> File -> <Proc, Exception> String
+postFileExample uri f = do
+ httpClient = buildClient clientBuilder
+ webTarget = target httpClient uri
+ builder = request webTarget
+ acceptMediaType builder [WILDCARD_TYPE]
+ invocation = buildPost builder $ entity f APPLICATION_OCTET_STREAM_TYPE
+ response = syncInvoke invocation
+ print $ statusCodeOf response
+ print $ statusMessageOf response
+ res = readEntity response
+ close httpClient
+ res
+
+postFileAsyncExample :: String -> File -> <Proc, Exception> ()
+postFileAsyncExample uri f = do
+ httpClient = buildClient clientBuilder
+ webTarget = target httpClient uri
+ builder = request webTarget
+ acceptMediaType builder [WILDCARD_TYPE]
+ mp = formDataMultiPart
+ invocation = buildPost builder $ entity f APPLICATION_OCTET_STREAM_TYPE
+ f = asyncInvoke invocation
+ (\response -> do
+ print $ statusCodeOf response
+ print $ statusMessageOf response
+ catch (do
+ content = ((readEntity response) :: String)
+ print $ length content
+ ) (\(t :: Throwable) -> print $ show t)
+ close httpClient
+ ()
+ )
+ (\throwable -> do
+ print $ show throwable
+ close httpClient
+ ()
+ )
+ print $ isFutureDone f
+*/
\ No newline at end of file