Advertisement
Guest User

Untitled

a guest
Oct 7th, 2015
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. public function uploadFileToS3(Request $request) {
  2. $image = Image::make($request->file('image'))->encode('jpg', 75);
  3. $s3 = Storage::disk('s3');
  4.  
  5. $image_file_name = $this->generateName($request->name) . '.jpg';
  6. $file_path = '/' . config('folder') . '/' . $request->page_id . '/' . $request->element_id . '/' . $request->page_to_element_id . '/' . $request->name . '/';
  7.  
  8. $s3->put($file_path.'original_'.$image_file_name, $image, 'public');
  9. $s3->put($file_path.'medium_'.$image_file_name, $image->fit(300, 300), 'public');
  10. $s3->put($file_path.'thumb_'.$image_file_name, $image->fit(100, 100), 'public');
  11.  
  12. return json_encode(array(
  13. 'filename' => $image_file_name
  14. ));
  15. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement