-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmultipart-upload.pwn
More file actions
30 lines (26 loc) · 873 Bytes
/
multipart-upload.pwn
File metadata and controls
30 lines (26 loc) · 873 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// multipart-upload.pwn — file upload via multipart/form-data.
//
// Demonstrates:
// * Building a multipart payload mixing text fields and a file field.
// * Letting the plugin set Content-Type with the correct boundary.
#include <a_samp>
#include <https_samp>
public OnGameModeInit()
{
https_multipart_add_text("title", "weekly report");
https_multipart_add_text("author", "erick");
https_multipart_add_file("attachment", "report.txt", "scriptfiles/report.txt");
https(1, HTTPS_POST, "https://httpbin.org/post", "", "OnUpload");
return 1;
}
forward OnUpload(index, response[], status, error);
public OnUpload(index, response[], status, error)
{
if (error != HTTPS_ERROR_NONE)
{
printf("[example] upload failed: error=%d", error);
return 1;
}
printf("[example] upload ok: status=%d", status);
return 1;
}