Download from Github

ripper121
Posts: 7
Joined: Wed Sep 19, 2018 9:28 am

Download from Github

Postby ripper121 » 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:

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&amp;X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20190226%2Fus-east-1%2Fs3%2Faws4_request&amp;X-Amz-Date=20190226T111034Z&amp;X-Amz-Expires=300&amp;X-Amz-Signature=a022971240dd76420af4b75632cf08dcfa946c057fd52d38e508150b624d8b3a&amp;X-Amz-SignedHeaders=host&amp;actor_id=0&amp;response-content-disposition=attachment%3B%20filename%3DGo-Play.fw&amp;response-content-type=application%2Foctet-stream">redirected</a>.</body></html>
When I try to download from the redirected URL I get no access :(
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);
}


ESP_Sprite
Posts: 9757
Joined: Thu Nov 26, 2015 4:08 am

Re: Download from Github

Postby ESP_Sprite » Wed Feb 27, 2019 4:12 am

Kinda hard to say, as we can't see what's going on on the Github side, but maybe Github needs the Referer: header to be set on the 2nd request?

ripper121
Posts: 7
Joined: Wed Sep 19, 2018 9:28 am

Re: Download from Github

Postby ripper121 » Wed Feb 27, 2019 7:49 am

Found the issue.
Github or the http client dont like unescaped http requests

karansoi
Posts: 9
Joined: Tue Jul 31, 2018 5:25 pm

Re: Download from Github

Postby karansoi » Mon Mar 11, 2019 6:22 am

@ripper121,
How did you download the file from github? Your solution may help others in the same situation.
Regards.

Who is online

Users browsing this forum: No registered users and 128 guests