Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download app after build #66

Closed
Scriptonita opened this issue Jun 17, 2017 · 1 comment
Closed

Download app after build #66

Scriptonita opened this issue Jun 17, 2017 · 1 comment

Comments

@Scriptonita
Copy link

Scriptonita commented Jun 17, 2017

Hi!!
I'm trying make a script to download the app after build succes.

phonegapbuild.build(datos, function(e, data) {
  if (e) {
    console.error("Fallo al compilar:", e);
  } else {
    //console.log("successfully built the app:", data);
    console.log("Se ha compilado con éxito!!");
    var file = fs.createWriteStream("myapp.apk");
    var request = https.get(
      //"https://build.phonegap.com/apps/xxxxxx/download/android", // This url fail too. 4,4Kb
      "https://build.phonegap.com/api/v1/apps/xxxxxx/android", // 61Bytes
      function(response) {
        response.pipe(file);
        console.log("Descargando versión android");
      }
    );   
  }
});

The first url download a 4,4Kb file, the second 61bytes.

I have also tried with:
https://www.npmjs.com/package/download
https://www.npmjs.com/package/request-progress

But the same thing happens.
If I go to the build.phonegap.com and click on the Apps link, I download a file aprox 12mb

Thanks!!

@Scriptonita
Copy link
Author

Already solved.

As happened to #63 phonegapBuild.on("login") never gets called.

If I change the extension apk to txt I can see that the content in files say that i need loggin.

This is the code that work for me:

phonegapbuild.login(datos, function(e, api) {
  console.log("Estás logeado en Phonegap Build");
  phonegapbuild.build(datos, function(e, data) {
    if (e) {
      console.error("Fallo al compilar:", e);
    } else {
      console.log("Se ha compilado con éxito!!");
      let android = fs.createWriteStream(datos.title + ".apk");
      api.get("/apps/XXXXXXX/android").pipe(android);
    }
  });
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant