-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstreaHTTPAsli.txt
103 lines (93 loc) · 6.32 KB
/
streaHTTPAsli.txt
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include <Arduino.h>
#include <LittleFS.h>
#include <WiFi.h>
#include <HTTPClient.h>
const char* ssid = "KONTRAKAN ALUMNI";
const char* password = "TMUA1443H";
String serverName = "storage.googleapis.com";
String serverPath = "/web-xerpihan.appspot.com/noot/sendFileBismillah.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=web-xerpihan%40appspot.gserviceaccount.com%2F20240103%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20240103T141238Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host&X-Goog-Signature=710710e65890706c5fd9989d62a6123b42a7054b536d4d3f570ca3fb1d6d49eb7462fa3723a7b9927af3b0d21fc58b2c4e8185933e9243330700b224a613ba6e03846ea2fdd6e95d2f8490534265316a03b5b07e5039737a797d2a5fd110a098daebb0312813935aca50f0a772d58de25cf869a6657818ab06e7e58776a290c88289ce7988ebf9c3b69294bf021b2048073ea02697a33fbc6a95fee817ebcb36b58c1235ffb485d7e3d0ebbdf1830cec3ae062241596d611cc93bca8a6773b3f7b7e059f9137f906afc325a3b2fb1a5da6e01d55b519ff1b16fdf347c90e41bd5c87a6393482322cff8bfa261c637d0237b612fd65d41505508f9d05c310b4fb"; // Path server langsung ke folder penyimpanan
const int serverPort = 443;
int httpCode;
const char filename[] = "/sendFileBismillah2.wav";
const char* test_root_ca = \
"-----BEGIN CERTIFICATE-----\n" \
"MIIFljCCA36gAwIBAgINAgO8U1lrN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occurred while mounting LittleFS");
ESP.restart();
}
else {
delay(500);
Serial.println("LittleFS mounted successfully");
}
}
HTTPClient http;
File file;
void setup() {
Serial.begin(115200);
initLittleFS();
WiFi.mode(WIFI_STA);
Serial.println();
Serial.print("Connecting to ");
Serial.println(ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED) {
Serial.print(".");
delay(500);
}
Serial.println();
Serial.print("IP Address: ");
Serial.println(WiFi.localIP());
}
void loop() {
file = LittleFS.open(filename);
// const size_t bufferSize = 1024*500;
uint8_t buffer[2048];
size_t bytesRead = file.readBytes((char*)buffer, 2048);
Serial.print("[HTTP] begin...\n");
// configure server and url
// http.begin(serverName, serverPort, serverPath, testb_root_ca);
http.begin("https://storage.googleapis.com/web-xerpihan.appspot.com/noot/sendFileBismillah2.wav?X-Goog-Algorithm=GOOG4-RSA-SHA256&X-Goog-Credential=web-xerpihan%40appspot.gserviceaccount.com%2F20240103%2Fauto%2Fstorage%2Fgoog4_request&X-Goog-Date=20240103T174632Z&X-Goog-Expires=900&X-Goog-SignedHeaders=host&X-Goog-Signature=6e151501f53145bdd362c7ec001766be1539fd217106a7ed365aac085691027da7f5dc2a8bc5496d53282ba00737010b959744f131e6b34a7a3450438207934a37530188afbd518149b00f3fddc69dd058acdd0c7a9b6e64e2d1fbd85ac8441cccfa5aa4311f632e8e264481abf910ff992b760fc3b55612a676035ce912926c50936f9bdb9e262c5bcc67550469adba7a6e6e95fbca5a8b99ac502f5b0134de95a4fd10dcfb569d3f41c0023e4220be4eb5c22b4fe8d2796c3b07f0120e88098c684964d7b3150bf89f373fe9fae1d36331f7ec192fad18b7b8939b2aad8503e3e3bfe03400b1b29beb5d244348b9c321188f3dbac1a770ae3685d704093f65", test_root_ca);
Serial.print("[HTTP] PUT...\n");
// start connection and send HTTP header
http.addHeader("File_name", filename);
http.addHeader("Content-Type", "application/octet-stream");
int httpCode = http.sendRequest("PUT",buffer, 2048);
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
Serial.printf("[HTTP] GET... code: %d\n", httpCode);
http.end();
}
delay(10000);
}