You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/content-types.md
+54-3Lines changed: 54 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,7 +11,10 @@ If you specify a content type of `'application/json'`, `HttpCommand` will automa
11
11
Content type `multipart/form-data` is commonly used to transfer files to a server or to send multiple types of content in the request payload. If you specify a content type of `'multipart/form-data'`:
12
12
13
13
*`Params` must be a namespace with named elements.
14
-
* Each element in `Params` consists of the data for the element optionally followed by a content type for the element.
14
+
* Each element in `Params` consists of up to 3 elements:
15
+
* content - the data for the element, if sending a file this is the file name (see the section below)
16
+
* type - the MIME content-type type for the element
17
+
* filename - if content is to be saved as a file, this is the filename for the content
15
18
* To send a file, prefix the file name with either:
16
19
*`@` to upload the file's content and its name
17
20
*`<` to upload just the file's content
@@ -22,17 +25,65 @@ In the example below:
22
25
* Extra newlines have been removed for compactness.
23
26
* The file `/tmp/foo.txt` contains `Hello World`.
24
27
* We create 4 parts to be sent with the request:
25
-
* a simple string
28
+
* a JSON array (with content type 'application/json')
26
29
* a named file - both the content and file name will be sent
30
+
* some in-workspace content to be saved as a file named 'data.txt'
31
+
* a simple string
27
32
* an unnamed file - only the content will be sent
28
-
* a JSON array (with content type 'application/json')
33
+
34
+
```
35
+
h←HttpCommand.New 'post' 'someurl.com'
36
+
p←⎕NS '' ⍝ create a namespace
37
+
p.json←'[1,2,3]' 'application/json' ⍝ value and content type
38
+
p.namedfile←'@/tmp/foo.txt' ⍝ @ = include the file name
39
+
p.saveasfile←'this is the content' 'text/plain' 'data.txt' ⍝ save content as a file
40
+
p.string←'/tmp/foo.txt' ⍝ just a value
41
+
p.unnamedfile←'</tmp/foo.txt' ⍝ < = do not include the file name
0 commit comments