public function test_Retreive_Saved_File_Instead_Of_Creating_New()
 {
     Storage::disk('s3')->deleteDir('tests/vParameters');
     Photo::find(1)->version(vParameters::class);
     $this->expectOutputString('');
     Photo::find(1)->version(vParameters::class, 'Image Created!');
 }
예제 #2
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array $data
  * @return User
  */
 protected function create(array $data)
 {
     if (isset($data['comprador'])) {
         $comprador = $data['comprador'];
     } else {
         $comprador = 0;
     }
     if (isset($data['vendedor'])) {
         $vendedor = $data['vendedor'];
     } else {
         $vendedor = 0;
     }
     if (isset($data['gestor'])) {
         $gestor = $data['gestor'];
     } else {
         $gestor = 0;
     }
     //$request =  Request::all();
     $file = $data['file'];
     $nombre = $file->getClientOriginalName();
     $hash = hash_file('md5', $file);
     \Storage::disk('local')->put("/camara/" . $nombre, \File::get($file));
     Empresa::create(['idEmpresa' => $data['email'], 'nombre' => $data['name'], 'nit' => $data['nit'], 'comprador' => $comprador, 'vendedor' => $vendedor, 'gestor' => $gestor, 'razonSocial' => $data['razonSocial'], 'idEmpresaResiduo' => $data['residuo'], 'telefono' => $data['telefono'], 'direccion' => $data['direccion'], 'camara' => $nombre, 'hash' => $hash]);
     return User::create(['name' => $data['name'], 'email' => $data['email'], 'password' => bcrypt($data['password'])]);
 }
예제 #3
0
 public function getImportSchema()
 {
     $contents = \Storage::disk("local")->get(ImporterController::FILE_SCHEMA);
     $this->filterContents($contents);
     $lines = $this->getLines($contents);
     $this->prepareSchemas($lines);
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store(Request $request)
 {
     //obtenemos el campo file definido en el formulario
     $file1 = $request->file('foto1');
     $file2 = $request->file('foto2');
     $file3 = $request->file('foto3');
     //        $input  = array('image' => $file1);
     //        $reglas = array('image' => 'mimes:jpeg,png');
     //        $validacion = Validator::make($input,  $reglas);
     //        if ($validacion->fails())
     //        {
     //            \Session::flash('flash_message', 'Una de las imagenes no es correcta');
     //        }
     //obtenemos el nombre del archivo
     $nombre1 = $file1->getClientOriginalName();
     $nombre2 = $file2->getClientOriginalName();
     $nombre3 = $file3->getClientOriginalName();
     //indicamos que queremos guardar un nuevo archivo en el disco local
     \Storage::disk('local')->put($nombre1, \File::get($file1));
     \Storage::disk('local')->put($nombre2, \File::get($file2));
     \Storage::disk('local')->put($nombre3, \File::get($file3));
     $persona = Persona::find($request->persona_id);
     $persona->fill($request->all());
     $persona->foto1 = $request->persona_id . '|' . $nombre1;
     $persona->foto2 = $request->persona_id . '|' . $nombre2;
     $persona->foto3 = $request->persona_id . '|' . $nombre3;
     $persona->save();
     return view('new');
 }
예제 #5
0
 public function postUpload(Request $req)
 {
     $response = array();
     if ($req->file('excelF')) {
         $file = $req->file('excelF');
         $extension = $file->getClientOriginalExtension();
         $filename = $file->getClientOriginalName();
         /*periksa extensi file */
         if ('xlsx' !== $extension) {
             $response['code'] = 404;
             $response['msg'] = "File berextensi {$extension} dengan nama {$filename}, file Seharusnya Berupa Excel";
             // $response['msg']="File Anda   $file->getClientOriginalName(), Pastikan File yang Anda upload sesuai dengan format ";
             return $response;
             // return $response;
         } elseif (\Storage::disk('local')->put($file->getFilename() . '.' . $extension, \File::get($file))) {
             // simpan kedadalam table
             $entry = new Fileentry();
             $entry->mime = $file->getClientMimeType();
             $entry->original_filename = $file->getClientOriginalName();
             $entry->filename = $file->getFilename() . '.' . $extension;
             $entry->save();
             $response['code'] = 200;
             $response['msg'] = "File  {$entry->original_filename} Telah disimpan";
             return $response;
         }
     }
     $response['code'] = 404;
     $response['msg'] = "Gagal Upload File !!!";
     return json_encode($response);
     // echo '{"TEST1": 454535353,"TEST2": "test2"}';
 }
 /**
  * Execute the job.
  *
  * @return void
  */
 public function handle()
 {
     $s3 = \Storage::disk('s3');
     $filePath = '/jacobsgroupvegas/properties/' . env('APP_ENV') . '/' . $this->mls . '/' . $this->filename;
     $s3->put($filePath, file_get_contents('/tmp' . '/property-' . $this->mls . '-image-' . $this->filename), 'public');
     dispatch((new KillImageFromDisk($this->localDiskImage))->onQueue('killImage'));
 }
예제 #7
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request  $request
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request)
 {
     $photoParent = PhotoParent::create($request->except('images', 'q'));
     // getting all of the post data
     $files = Input::file('images');
     $result = array();
     $file_count = count($files);
     // start count how many uploaded
     $uploadcount = 0;
     foreach ($files as $key => $file) {
         // $rules = array('file' => 'required'); //'required|mimes:png,gif,jpeg,txt,pdf,doc'
         // $validator = Validator::make(array('file'=> $file), $rules);
         // if($validator->passes()){
         $storage = \Storage::disk('public');
         $destinationPath = 'froala/uploads';
         $storage->makeDirectory($destinationPath);
         $filename = time() . $key . '.' . $file->getClientOriginalExtension();
         $upload_success = $file->move($destinationPath, $filename);
         $file_array = array();
         $file_array = array_collapse([$file_array, ['id' => $key + 1, 'name' => $filename]]);
         $result = array_add($result, $key, $file_array);
         $jsonresult = json_encode($result);
         //$files_ser = serialize($result);
         $photoParent->images = $jsonresult;
         $photoParent->save();
         $uploadcount++;
         // } // endif
     }
     return redirect()->route('admin.photoParent.index');
 }
 public function store(Request $request)
 {
     //dd('jajaja');
     $file = $request->file('file');
     //obtenemos el campo file obtenido por el formulario
     $nombre = $file->getClientOriginalName();
     //indicamos que queremos guardar un nuevo archivo en el disco local
     \Storage::disk('local')->put($nombre, \File::get($file));
     \Excel::load('/storage/public/files/' . $nombre, function ($archivo) use(&$falla) {
         $result = $archivo->get();
         //leer todas las filas del archivo
         foreach ($result as $key => $value) {
             $var = new Periodo();
             $datos = ['bloque' => $value->bloque, 'inicio' => $value->inicio, 'fin' => $value->fin];
             $validator = Validator::make($datos, Periodo::storeRules());
             if ($validator->fails()) {
                 Session::flash('message', 'Los Periodos ya existen o el archivo ingresado no es valido');
                 $falla = true;
             } else {
                 $var->fill($datos);
                 $var->save();
             }
         }
     })->get();
     if ($falla) {
         // Fallo la validacion de algun campus, retornar al index con mensaje
         return redirect()->route('Administrador.periodos.index');
     }
     \Storage::delete($nombre);
     Session::flash('message', 'Los Periodos fueron agregados exitosamente!');
     return redirect()->route('Administrador.periodos.index');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @param CreatePersonRequest $request
  * @return Response
  */
 public function postStorepeople(CreatePersonRequest $request)
 {
     $people = new People();
     $people->document = $request->get('document');
     $people->names = $request->get('names');
     $people->surnames = $request->get('surnames');
     $people->date_of_birth = $request->get('date_of_birth');
     $people->landline = $request->get('landline');
     $people->address = $request->get('address');
     $people->date_of_admission = $request->get('date_of_admission');
     $people->cellular = $request->get('cellular');
     $upload_dir = \Storage::disk('photos');
     $img = $request->get('photo');
     $img = str_replace('data:image/png;base64,', '', $img);
     $data = base64_decode($img);
     $name = date('YmdHis') . '.png';
     $upload_dir->put($name, $data);
     $people->photo = $name;
     $people->save();
     $email = $request->get('email');
     $password = $request->get('password');
     $user = new User(['email' => $email, 'password' => $password]);
     $people->user()->save($user);
     Session::flash('message', 'Usuario registro correctamente en el sistema.');
     return redirect('auth/login');
 }
예제 #10
0
 public function save(Request $request)
 {
     $titulo = $request->titulo;
     $idtutor = $request->idtutor;
     $idrevisor = $request->idrevisor;
     $idlinea = $request->type;
     $descripcion = $request->descripcion;
     //obtenemos el campo file definido en el formulario
     $file = $request->file('archivo');
     //obtenemos el nombre del archivo
     $nombre = $file->getClientOriginalName();
     $url = storage_path('app/') . $nombre;
     $messages = ['mimes' => 'Solo se permiten Archivos .pdf, .doc, .docx.'];
     $validator = Validator::make(['titulo' => $titulo, 'file' => $file, 'nombre' => $nombre], ['titulo' => 'required|max:255', 'file' => 'mimes:doc,docx,pdf'], $messages);
     $message = 'f';
     if ($validator->fails()) {
         return redirect('sistema/nuevotrabajo')->withErrors($validator);
     }
     $carbon = new Carbon();
     //indicamos que queremos guardar un nuevo archivo en el disco local
     \Storage::disk('local')->put($nombre, \File::get($file));
     $nuevo_Trabajo = new Trabajo();
     $nuevo_Trabajo->titulo = $titulo;
     $nuevo_Trabajo->nombreArchivo = $nombre;
     $nuevo_Trabajo->rutaArchivo = $url;
     $nuevo_Trabajo->user_id = Auth::user()->id;
     $nuevo_Trabajo->tutor_id = $idtutor;
     $nuevo_Trabajo->linea_id = $idlinea;
     $nuevo_Trabajo->Descripcion = $descripcion;
     $nuevo_Trabajo->fecha = $carbon->now(new \DateTimeZone('America/La_Paz'));
     $nuevo_Trabajo->save();
     return redirect('sistema/nuevotrabajo')->with(['success' => ' ']);
 }
 public function store(Request $request)
 {
     //dd('jajaja');
     $file = $request->file('file');
     //obtenemos el campo file obtenido por el formulario
     $nombre = $file->getClientOriginalName();
     //indicamos que queremos guardar un nuevo archivo en el disco local
     \Storage::disk('local')->put($nombre, \File::get($file));
     $campus = $request->get('campus');
     $tipos = $request->get('tipos');
     \Excel::load('/storage/public/files/' . $nombre, function ($archivo) use($campus, $tipos) {
         $result = $archivo->get();
         //leer todas las filas del archivo
         foreach ($result as $key => $value) {
             $campus = Campus::whereNombre($value->campus_id)->pluck('id');
             $tipos = TipoSala::whereNombre($value->tipo_sala_id)->pluck('id');
             //echo $facultades."<br>";
             if (is_null($campus)) {
                 // El campus no existe, deberia hacer algo para mitigar esto, o retornarlo al usuario ...
             }
             if (is_null($tipos)) {
                 // El campus no existe, deberia hacer algo para mitigar esto, o retornarlo al usuario ...
             }
             //if(!Sala::whereNombre('campus_id',$campus)->whereNombre('tipo_sala_id',$tipos)->first()){
             if (!Sala::where('nombre', $value->nombre)->first()) {
                 $var = new Sala();
                 $var->fill(['nombre' => $value->nombre, 'descripcion' => $value->descripcion, 'capacidad' => $value->capacidad, 'campus_id' => $campus, 'tipo_sala_id' => $tipos]);
                 $var->save();
             }
         }
     })->get();
     \Storage::delete($nombre);
     Session::flash('message', 'Las Salas fueron agregadas exitosamente!');
     return redirect()->route('Encargado.salas.index');
 }
예제 #12
0
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle(Request $request, Closure $next)
 {
     // https://developers.google.com/identity/protocols/OAuth2WebServer
     $this->client->setAccessType('offline');
     // To get a refresh token, per <http://stackoverflow.com/a/31237203/489916>
     $this->client->setApprovalPrompt('force');
     if (\Storage::disk('local')->exists('google_access_token.json')) {
         $token = \Storage::disk('local')->get('google_access_token.json');
         $this->client->setAccessToken($token);
     }
     if ($request->path() == 'oauth2callback' && $request->has('code')) {
         if ($request->session()->get('google_oauth_state') !== $request->get('state')) {
             abort(500, 'The session state did not match.');
         }
         $this->client->authenticate($request->get('code'));
         \Storage::disk('local')->put('google_access_token.json', $this->client->getAccessToken());
         return redirect('/');
     } elseif (is_null($this->client->getAccessToken())) {
         // If the user hasn't authorized the app, initiate the OAuth flow
         $state = strval(mt_rand());
         $this->client->setState($state);
         $request->session()->put('google_oauth_state', $state);
         $authUrl = $this->client->createAuthUrl();
         return response()->view('google.authorize', ['authUrl' => $authUrl]);
     }
     return $next($request);
 }
예제 #13
0
function salvaArquivosLocal($local, $arquivo, $prefix)
{
    $extArquivo = $arquivo->getClientOriginalExtension();
    $nomeArquivo = $prefix . '.' . $extArquivo;
    $salvaArquivo = Storage::disk($local)->put($nomeArquivo, File::get($arquivo));
    return $nomeArquivo;
}
예제 #14
0
 public function setPathAttribute($path)
 {
     $this->attributes['path'] = 'doc_' . time() . '.' . $path->getClientOriginalName();
     $name = 'doc_' . time() . '.' . $path->getClientOriginalName();
     //$name = Carbon::now()->second.$path->getClientOriginalName();
     \Storage::disk('local')->put($name, \File::get($path));
 }
예제 #15
0
 public function run($token)
 {
     $env = Environment::where('token', $token)->first();
     if (is_null($env)) {
         return json_encode(['error' => true, 'output' => 'invalid token']);
     }
     if (\Storage::exists($token . '.php')) {
         $tokenFile = \Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix() . "/" . $token . ".php";
         $output = null;
         $error = false;
         foreach ($this->steps as $step) {
             $command = "dep --ansi --file={$tokenFile} {$step} " . $env->server->host;
             $output .= $command . "\n";
             $process = new Process($command);
             $process->run();
             if (!$process->isSuccessful()) {
                 $output .= $process->getErrorOutput();
                 $error = true;
                 break;
             } else {
                 $output .= $process->getOutput();
             }
         }
         $history = EnvironmentHistory::create(['environment_id' => $env->id, 'status' => $error ? 'fail' : 'success', 'history' => $output]);
         return json_encode(['error' => $error, 'output' => $output]);
     }
 }
예제 #16
0
 public function saveProfile(Request $request)
 {
     $data = $request->all();
     $validator = $this->validator($data);
     if ($validator->fails()) {
         $this->throwValidationException($request, $validator);
     }
     $user = User::find(\Auth::user()->id);
     if (is_object($data['photo'])) {
         $photo = $data['photo'];
         $name = str_replace('.', '_' . $user->id . '.', $photo->getClientOriginalName());
         \Storage::disk('local')->put($name, \File::get($photo));
         $user->photo = $name;
     }
     $user->first_name = $data['first_name'];
     $user->last_name = $data['last_name'];
     $user->birthday = $data['birthday'];
     $user->gender = $data['gender'];
     $user->phone = $data['phone'];
     $user->street = $data['street'];
     $user->number = $data['number'];
     $user->neighborhood = $data['neighborhood'];
     $user->zip_code = $data['zip_code'];
     $user->city = $data['city'];
     $user->state = $data['state'];
     $user->country = $data['country'];
     $user->save();
     return redirect('perfil-paciente')->with('success', 'Se han guardado los cambios con éxito.');
 }
예제 #17
0
 public function setPathAttribute($path)
 {
     if (!empty($path)) {
         $name = Carbon::now()->second . $path->getClientOriginalName();
         $this->attributes['path'] = $name;
         \Storage::disk('local')->put($name, \File::get($path));
     }
 }
예제 #18
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function show($id)
 {
     $pdf = StoredPdf::find($id);
     if ($pdf) {
         return \Response::make(\Storage::disk('local')->get($pdf->id . '.pdf'), 200, ['Content-Type' => 'application/pdf', 'Content-Disposition' => 'inline; ' . $pdf->title]);
     }
     return redirect()->back();
 }
예제 #19
0
 private function deleteFromStorage($path)
 {
     if (\Storage::disk($this->config["disk"])->getDriver()->has($path . $this->getFileName())) {
         \Storage::disk($this->config["disk"])->getDriver()->deleteDir($path);
     } else {
         //maybe logging
     }
 }
예제 #20
0
 public function getDelete()
 {
     $exists = \Storage::disk('s3')->has('test3.txt');
     if ($exists) {
         \Storage::disk('s3')->delete('test3.txt');
         return 'done';
     }
 }
예제 #21
0
 public function setImageAttribute($image)
 {
     if (!empty($image)) {
         $this->attributes['image'] = Carbon::now()->second . $image->getClientOriginalName();
         $name = Carbon::now()->second . $image->getClientOriginalName();
         \Storage::disk('local')->put($name, \File::get($image));
     }
 }
예제 #22
0
 public function upload()
 {
     $file = $request->file('img');
     //obtenemos el nombre del archivo
     $nombre = $file->getClientOriginalName();
     //indicamos que queremos guardar un nuevo archivo en el disco local
     \Storage::disk('local')->put($nombre, \File::get($file));
 }
예제 #23
0
 public function setPathAttribute($path)
 {
     if (!empty($path)) {
         $this->attributes['path'] = Carbon::now()->year . Carbon::now()->month . Carbon::now()->day . Carbon::now()->hour . Carbon::now()->minute . Carbon::now()->second . '-estudiante-' . $path->getClientOriginalName();
         $name = Carbon::now()->year . Carbon::now()->month . Carbon::now()->day . Carbon::now()->hour . Carbon::now()->minute . Carbon::now()->second . '-estudiante-' . $path->getClientOriginalName();
         \Storage::disk('local')->put($name, \File::get($path));
     }
 }
예제 #24
0
 public function createNewFile()
 {
     $path = storage_path();
     $fileName = $path . "\\temp\\tempEdit1.txt";
     Storage::disk('local')->put('file.txt', 'Contents');
     if (!File::exists($fileName)) {
         File::put($fileName, '');
     }
 }
예제 #25
0
 /**
  * Create a new task.
  *
  * @param  Request  $request
  * @return Response
  */
 public function store(Request $request)
 {
     $this->validate($request, ['name' => 'required|max:255', 'photo' => 'image']);
     $file = $request->file('photo');
     $image_name = time() . "-" . $file->getClientOriginalName();
     \Storage::disk('local')->put($image_name, \File::get($file));
     $request->user()->tasks()->create(['name' => $request->name, 'photo' => $image_name]);
     return redirect('/tasks');
 }
 /**
  * @param Request $request
  * @return \Illuminate\View\View
  */
 public function postUpload(Request $request)
 {
     $upload_dir = \Storage::disk('photos');
     $img = $request->get('hidden_data');
     $img = str_replace('data:image/png;base64,', '', $img);
     $data = base64_decode($img);
     $upload_dir->put(time() . '.png', $data);
     return view('advice.placement.canvas');
 }
예제 #27
0
 protected function mockStorage()
 {
     Storage::extend('mock', function () {
         return \Mockery::mock(\Illuminate\Contracts\Filesystem\Filesystem::class);
     });
     Config::set('filesystems.disks.mock', ['driver' => 'mock']);
     Config::set('filesystems.default', 'mock');
     return Storage::disk();
 }
 public static function deleteThumbnail($thumbnail_url)
 {
     $storage = \Storage::disk(self::$storage_type);
     $url = self::removeUrlAppend($thumbnail_url);
     $exists = $storage->exists($url);
     if ($exists) {
         $storage->delete($url);
     }
 }
예제 #29
0
 /**
  * Display the specified resource.
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $photo = Photo::findOrFail($id);
     $storagePath = \Storage::disk('local')->getDriver()->getAdapter()->getPathPrefix();
     $url = $storagePath . $photo->image_url;
     $photo->image_url = $url;
     $data = ['photo' => $photo];
     return view('photo.show', $data);
 }
 /**
  * Handle the event.
  *
  * @param  ProductCreate  $event
  * @return void
  */
 public function handle(ProductCreate $event)
 {
     if (!\Storage::disk('uploads')->exists($event->product->model)) {
         try {
             \Storage::disk('uploads')->makeDirectory($event->product->model);
         } catch (\Exception $ex) {
             \Log::error($ex->getFile() . ' - ' . $ex->getMessage());
         }
     }
 }