public function check(Request $request)
 {
     $pkgname = $request->input('pkgname', 'www.chasetch.com');
     $version = $request->input('version', 0);
     $filemd5 = $request->input('md5', 0);
     $deviceid = $request->id;
     $apk = Apk::where('pkgname', $pkgname)->first();
     if (!empty($apk)) {
         if ($apk->version > $version) {
             echo "have update\n";
             echo action('Api\\UpdateapkController@download', array('token' => $apk->token, 'filename' => $apk->filename)) . "\n";
         } else {
             echo "no update available\n";
         }
     } else {
         echo "apk not found\n";
     }
 }
 public function download(Request $request, $token, $filename)
 {
     $apk = Apk::where('token', $token)->where('filename', $filename)->first();
     if (!empty($apk)) {
         $pathToFile = storage_path() . "/apk/" . $apk->pkgname . "/" . $apk->filename;
         $apk->downloads = $apk->downloads + 1;
         $apk->update();
         $file = $pathToFile;
         //not public folder
         if (file_exists($file)) {
             header('Content-Description: File Transfer');
             header('Content-Type: application/vnd.android.package-archive');
             header('Content-Disposition: attachment; filename=' . basename($file));
             header('Content-Transfer-Encoding: binary');
             header('Expires: 0');
             header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
             header('Pragma: public');
             header('Content-Length: ' . filesize($file));
             readfile($file);
             exit;
         }
     }
 }
Esempio n. 3
0
 public function latest()
 {
     $apk = Apk::first();
     $path = base_path() . '/storage/apk/' . $apk->pkgname . '/' . $apk->filename;
     // dd(filesize($path));
     // return \Response::download($path, $filename);
     header('Content-Type: application/vnd.android.package-archive');
     header('Content-Disposition: attachment; filename="' . $apk->filename . '"');
     header('Content-Length: ' . filesize($path));
     readfile($path);
     // header('Content-Description: File Transfer');
     // header('Content-Type: application/vnd.android.package-archive');
     // header('Content-Type: application/vnd.android.package-archive');
     // header('Content-Disposition: attachment; filename="'.$apk->filename.'"');
     // header('Content-Transfer-Encoding: binary');
     // header('Expires: 0');
     // header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
     // header('Pragma: public');
     // header('Content-Length: ' . filesize($path));
     // ob_clean();
     // flush();
     // readfile($path);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($id)
 {
     $apk = Apk::findOrFail($id);
     $path = base_path() . '/storage/apk/' . $apk->pkgname;
     \File::deleteDirectory($path);
     $apk->delete();
     Session::flash('flash_class', 'alert-success');
     Session::flash('flash_message', 'Apk successfully deleted.');
     return redirect()->route("apk.index");
 }