daily pastebin goal
60%
SHARE
TWEET

Untitled

a guest Jun 13th, 2018 43 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $.ajaxSetup({
  2.     headers: {
  3.         'Authorization': 'Bearer ' + token
  4. });
  5.  
  6. $.get('/api//download?' + $.param({
  7.      file: encodeURIComponent(fileNonPublicPath) //e.g. company_id/file.pdf
  8. }))
  9. .done((data) => {
  10.      console.log('file content', data);
  11. })
  12. .fail((err) => {
  13.       console.error(err);
  14. });
  15.    
  16. $file = urldecode($request->input('file'));
  17. $user = JWTAuth::toUser($request->token);
  18. if(checkUserRole($user,$file){
  19.    $pathToFile = Storage::disk('documents')->getDriver()->getAdapter()->applyPathPrefix($file);
  20.    $finfo = finfo_open(FILEINFO_MIME_TYPE);
  21.    $mime = finfo_file($finfo, $pathToFile);
  22.    finfo_close($finfo);
  23.    $headers = array('Content-Type' => $mime,);
  24.    return response()->download($pathToFile, $documento->nome);
  25. }
  26. return response()->json([], 403); //forbidden
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top