diff options
-rw-r--r-- | include/types.h | 2 | ||||
-rw-r--r-- | include/urweb.h | 1 | ||||
-rw-r--r-- | lib/ur/basis.urs | 1 | ||||
-rw-r--r-- | src/c/driver.c | 2 | ||||
-rw-r--r-- | src/c/urweb.c | 6 | ||||
-rw-r--r-- | tests/blob.ur | 5 |
6 files changed, 12 insertions, 5 deletions
diff --git a/include/types.h b/include/types.h index 69407b07..90a9f524 100644 --- a/include/types.h +++ b/include/types.h @@ -29,7 +29,7 @@ typedef struct { } uw_Basis_channel; typedef struct uw_Basis_file { - uw_Basis_string name; + uw_Basis_string name, type; uw_Basis_blob data; } uw_Basis_file; diff --git a/include/urweb.h b/include/urweb.h index 46eaab5f..cba746d4 100644 --- a/include/urweb.h +++ b/include/urweb.h @@ -163,5 +163,6 @@ uw_Basis_string uw_Basis_makeSigString(uw_context, uw_Basis_string); uw_Basis_string uw_Basis_sigString(uw_context, uw_unit); uw_Basis_string uw_Basis_fileName(uw_context, uw_Basis_file); +uw_Basis_string uw_Basis_fileMimeType(uw_context, uw_Basis_file); uw_Basis_blob uw_Basis_fileData(uw_context, uw_Basis_file); diff --git a/lib/ur/basis.urs b/lib/ur/basis.urs index bae58674..1068ddb9 100644 --- a/lib/ur/basis.urs +++ b/lib/ur/basis.urs @@ -516,6 +516,7 @@ val checkbox : formTag bool [] [Checked = bool] type file val fileName : file -> option string +val fileMimeType : file -> string val fileData : file -> blob val upload : formTag file [] [Value = string, Size = int] diff --git a/src/c/driver.c b/src/c/driver.c index 6e06f32b..c95f8886 100644 --- a/src/c/driver.c +++ b/src/c/driver.c @@ -393,7 +393,7 @@ static void *worker(void *data) { part += boundary_len; if (filename) { - uw_Basis_file f = {filename, {part_len, after_sub_headers}}; + uw_Basis_file f = {filename, type, {part_len, after_sub_headers}}; uw_set_file_input(ctx, name, f); } else diff --git a/src/c/urweb.c b/src/c/urweb.c index a73371ef..ff4d5c8f 100644 --- a/src/c/urweb.c +++ b/src/c/urweb.c @@ -632,7 +632,7 @@ uw_Basis_file uw_get_file_input(uw_context ctx, int n) { case UNSET: { char *data = uw_malloc(ctx, 0); - uw_Basis_file f = {"", {0, data}}; + uw_Basis_file f = {NULL, "", {0, data}}; return f; } case FIL: @@ -2128,6 +2128,10 @@ uw_Basis_string uw_Basis_fileName(uw_context ctx, uw_Basis_file f) { return f.name; } +uw_Basis_string uw_Basis_fileMimeType(uw_context ctx, uw_Basis_file f) { + return f.type; +} + uw_Basis_blob uw_Basis_fileData(uw_context ctx, uw_Basis_file f) { return f.data; } diff --git a/tests/blob.ur b/tests/blob.ur index 37c3f753..2d58faae 100644 --- a/tests/blob.ur +++ b/tests/blob.ur @@ -1,9 +1,10 @@ sequence s -table t : { Id : int, Nam : option string, Data : blob, Desc : string } +table t : { Id : int, Nam : option string, Data : blob, Desc : string, Typ : string } fun save r = id <- nextval s; - dml (INSERT INTO t (Id, Nam, Data, Desc) VALUES ({[id]}, {[fileName r.Data]}, {[fileData r.Data]}, {[r.Desc]})); + dml (INSERT INTO t (Id, Nam, Data, Desc, Typ) + VALUES ({[id]}, {[fileName r.Data]}, {[fileData r.Data]}, {[r.Desc]}, {[fileMimeType r.Data]})); main () and main () = return <xml><body> |