diff options
author | bptato <nincsnevem662@gmail.com> | 2023-06-08 08:03:16 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-06-08 08:03:16 +0200 |
commit | 00d7836d8a3d0101bd282e3acce58d65ed0220fe (patch) | |
tree | 70ff6f736277ab277bf527b4e3b79771bb7e3935 /src/xhr | |
parent | 23339918fa58f570a2b12bc7c7e78d4d8681b9a2 (diff) | |
download | chawan-00d7836d8a3d0101bd282e3acce58d65ed0220fe.tar.gz |
Remove JSObject again, add File API constructor
Diffstat (limited to 'src/xhr')
-rw-r--r-- | src/xhr/formdata.nim | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/xhr/formdata.nim b/src/xhr/formdata.nim index 9b45e7ba..cbb9f63e 100644 --- a/src/xhr/formdata.nim +++ b/src/xhr/formdata.nim @@ -40,13 +40,19 @@ proc append*(this: FormData, name: string, value: Blob, )) #TODO hack -proc append(this: FormData, name: string, value: JSObject, +proc append(ctx: JSContext, this: FormData, name: string, value: JSValue, filename = none(string)) {.jsfunc.} = - let blob = fromJS[Blob](value.ctx, value.val) + let blob = fromJS[Blob](ctx, value) if blob.isSome: - this.append(name, blob.get, filename.get("blob")) + let filename = if filename.isSome: + filename.get + elif blob.get of WebFile: + WebFile(blob.get).name + else: + "blob" + this.append(name, blob.get, filename) else: - let s = fromJS[string](value.ctx, value.val) + let s = fromJS[string](ctx, value) # toString should never fail (?) this.append(name, s.get, filename.get("")) |