Download from Github
Posted: Tue Feb 26, 2019 11:17 am
Hi ,
at the moment Im working on a FW updater which is using GITHUB as a source.
But I'm stuck at the point where I want to download the Firmware File:
When I execude that http Get I end up with this:
When I try to download from the redirected URL I get no access
https://github-production-release-asset ... tet-stream
at the moment Im working on a FW updater which is using GITHUB as a source.
But I'm stuck at the point where I want to download the Firmware File:
When I execude that http Get I end up with this:
Code: Select all
<html><body>You are being <a href="https://github-production-release-asset-2e65be.s3.amazonaws.com/137759166/b8044e80-c7b8-11e8-88a7-2215f147170d?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190226%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20190226T111034Z&X-Amz-Expires=300&X-Amz-Signature=a022971240dd76420af4b75632cf08dcfa946c057fd52d38e508150b624d8b3a&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3DGo-Play.fw&response-content-type=application%2Foctet-stream">redirected</a>.</body></html>
https://github-production-release-asset ... tet-stream
Code: Select all
/**
StreamHTTPClient.ino
Created on: 24.05.2015
*/
#include <Arduino.h>
#include <WiFi.h>
#include <WiFiMulti.h>
#include <HTTPClient.h>
#define USE_SERIAL Serial
WiFiMulti wifiMulti;
String latestURL = "https://github.com/OtherCrashOverride/go-play/releases/download/20181004/Go-Play.fw";
void setup() {
USE_SERIAL.begin(115200);
USE_SERIAL.println();
USE_SERIAL.println();
USE_SERIAL.println();
wifiMulti.addAP("SSID", "PASS");
}
void loop() {
// wait for WiFi connection
if ((wifiMulti.run() == WL_CONNECTED)) {
HTTPClient http;
USE_SERIAL.print("[HTTP] begin...\n");
// configure server and url
http.begin(latestURL);
//http.begin("192.168.1.12", 80, "/test.html");
USE_SERIAL.print("[HTTP] GET...\n");
// start connection and send HTTP header
int httpCode = http.GET();
if (httpCode > 0) {
// HTTP header has been send and Server response header has been handled
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
// file found at server
// get lenght of document (is -1 when Server sends no Content-Length header)
int len = http.getSize();
// create buffer for read
uint8_t buff[128] = { 0 };
// get tcp stream
WiFiClient * stream = http.getStreamPtr();
// read all data from server
while (http.connected() && (len > 0 || len == -1)) {
// get available data size
size_t size = stream->available();
if (size) {
// read up to 128 byte
int c = stream->readBytes(buff, ((size > sizeof(buff)) ? sizeof(buff) : size));
// write it to Serial
USE_SERIAL.write(buff, c);
if (len > 0) {
len -= c;
}
}
delay(1);
}
USE_SERIAL.println();
USE_SERIAL.print("[HTTP] connection closed or file end.\n");
} else {
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
delay(10000);
}