// retoor <retoor@molodetz.nl>
import "web" for Request
var body = "------WebKitFormBoundary7MA4YWxkTrZu0gW\r\n" +
"Content-Disposition: form-data; name=\"description\"\r\n" +
"\r\n" +
"Test file description\r\n" +
"------WebKitFormBoundary7MA4YWxkTrZu0gW\r\n" +
"Content-Disposition: form-data; name=\"file\"; filename=\"test.txt\"\r\n" +
"Content-Type: text/plain\r\n" +
"\r\n" +
"Hello, World!\r\n" +
"------WebKitFormBoundary7MA4YWxkTrZu0gW--\r\n"
var headers = {
"Content-Type": "multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW"
}
var request = Request.new_("POST", "/upload", {}, headers, body, {}, null)
var form = request.form
System.print(form["description"]) // expect: Test file description
System.print(form["file"]["filename"]) // expect: test.txt
System.print(form["file"]["content"]) // expect: Hello, World!
System.print(form["file"]["content_type"]) // expect: text/plain