function deleteFromS3($key, $key_type = 'folder') { $s3 = AWS::createClient('s3'); if ($key_type == 'file') { $key = str_replace(Config::get('aws.s3_assets_uri') . '/', '', $key); } $result = $s3->deleteMatchingObjects(Config::get('aws.bucket'), $key); }
public function setColors() { AWS::createClient('s3')->getObject(array('Bucket' => Credential::AWSS3BucketLargeThumbs, 'Key' => $this->bannerImage->filename, 'SaveAs' => public_path() . '/media/temp/' . $this->bannerImage->filename)); // Fetch an RGB array of the dominant color $rgb = ColorThief::getColor(public_path() . '/media/temp/' . $this->bannerImage->filename); // Unlink the file, it is no longer needed. unlink(public_path() . '/media/temp/' . $this->bannerImage->filename); // Convert RGB array to hex $hex = '#' . dechex($rgb[0]) . dechex($rgb[1]) . dechex($rgb[2]); // Set properties $this->attributes['dark_color'] = $hex; $this->attributes['light_color'] = '#' . (new Color($hex))->lighten(); }
public function fire($job, $data) { $s3 = \AWS::createClient('s3'); try { $response = $s3->getObject(array('Bucket' => $data['bucket'], 'Key' => $data['key'])); } catch (Exception $e) { return; } $imagine = new Imagine(); $image = $imagine->load((string) $response->get('Body')); $size = new Box(100, 100); $thumb = $image->thumbnail($size); $s3->putObject(array('Bucket' => 'bellated', 'Key' => $data['hash'] . '_100x100.' . $data['ext'], 'Body' => $thumb->get($data['ext']), 'ContentType' => $data['mimetype'])); // Probaby save these to a database here }
| */ Route::get('/', function () { return View::make('hello'); }); Route::get('/complete', function () { return View::make('complete'); }); Route::get('lord', function () { $user = getenv('DB_USERNAME'); dd($user); }); // Upload an image to S3 and // create a job to process it Route::post('/', function () { $validator = Validator::make(Input::all(), array('title' => 'required', 'file' => 'required|mimes:jpeg,jpg,png')); if ($validator->fails()) { return Redirect::to('/'); } // Upload File $file = Input::file('file'); $now = new DateTime(); $hash = md5($file->getClientOriginalName() . $now->format('Y-m-d H:i:s')); $key = $hash . '.' . $file->getClientOriginalExtension(); $s3 = AWS::createClient('s3'); $s3->putObject(array('Bucket' => 'bellated', 'Key' => $key, 'SourceFile' => $file->getRealPath(), 'ContentType' => $file->getClientMimeType())); // Create job Queue::push('\\Proc\\Worker\\ImageProcessor', array('bucket' => 'bellated', 'hash' => $hash, 'key' => $key, 'ext' => $file->getClientOriginalExtension(), 'mimetype' => $file->getClientMimeType())); Log::info('queue processed'); return Redirect::to('/complete'); });