Exemplo n.º 1
0
 /**
  * Displays the user administration
  */
 public function download($id)
 {
     $request = \App\Models\SharedFile::find($id);
     $now = \Carbon\Carbon::now();
     $expires = $request->request->expires_at;
     if ($now->timestamp < $expires->timestamp) {
         $file = $request->file;
         $path = $file->path;
         $rackRepo = new \App\Repositories\Rackspace();
         $container = $rackRepo->getRackspaceContainer();
         $distantFile = $container->getObject($path);
         $url = $distantFile->getTemporaryUrl(60, 'GET');
         return \Redirect::away($url);
     } else {
         return view('share.expired');
     }
 }
Exemplo n.º 2
0
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     try {
         $file = $this->file;
         $file->status = 'PENDING';
         $file->save();
         $rackRepo = new \App\Repositories\Rackspace();
         $container = $rackRepo->getRackspaceContainer();
         $path = storage_path('user-data/' . $file->path);
         if ($container->uploadObject($file->path, fopen($path, 'r+'))) {
             $file->status = 'UPLOADED';
             $file->save();
             unlink($path);
             $file->status = 'PROCESSED';
             $file->save();
         }
     } catch (\Exception $e) {
         echo 'Cannot send the file';
         $file = $this->file;
         $file->status = 'FAILED';
         $file->save();
     }
 }