Created
January 13, 2014 12:51
-
-
Save scottmcarthur/8399716 to your computer and use it in GitHub Desktop.
ServiceStack Upload with Multipart. (Working)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
POST /upload HTTP/1.1 | |
Host: localhost:8082 | |
Connection: keep-alive | |
Content-Length: 15911 | |
Cache-Control: max-age=0 | |
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8 | |
Origin: http://localhost:8082 | |
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 | |
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryDFhxbgBQ7QdO2KAr | |
Referer: http://localhost:8082/index.html | |
Accept-Encoding: gzip,deflate,sdch | |
Accept-Language: en-US,en;q=0.8 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html> | |
<head> | |
<title>Test</title> | |
</head> | |
<body> | |
<form action="/upload" method="POST" enctype="multipart/form-data"> | |
<h1>Upload File</h1> | |
<input type="file" name="File1" /> | |
<input type="submit" value="Upload" /> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using ServiceStack; | |
namespace Testv4 | |
{ | |
class MainClass | |
{ | |
public static void Main() | |
{ | |
var appHost = new AppHost(500); | |
appHost.Init(); | |
appHost.Start("http://*:8082/"); | |
Console.ReadKey(); | |
} | |
} | |
public class TestApp | |
{ | |
[Route("/upload", "POST")] | |
public class UploadFileRequest {} | |
public class TestController : Service | |
{ | |
public void Any(UploadFileRequest request) | |
{ | |
Console.WriteLine(Request.Files.Length); | |
} | |
} | |
} | |
public class AppHost : AppHostHttpListenerPoolBase | |
{ | |
public AppHost(int poolSize) : base("Test Service", poolSize, typeof(TestApp).Assembly) | |
{ | |
} | |
public override void Configure(Funq.Container container) | |
{ | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment