save pdf to google
Showing
6 changed files
with
359 additions
and
10 deletions
| ... | @@ -141,7 +141,8 @@ class ApiController extends Controller | ... | @@ -141,7 +141,8 @@ class ApiController extends Controller |
| 141 | $pdf = $pdf->pdf($pdfId); | 141 | $pdf = $pdf->pdf($pdfId); |
| 142 | $response = $pdfId; | 142 | $response = $pdfId; |
| 143 | $statusCode = 200; | 143 | $statusCode = 200; |
| 144 | 144 | $UploaqdPdf = new GoogledriveuploadpdfController(); | |
| 145 | $UploaqdPdf = $UploaqdPdf->google_drive_upload($folder, 'new_'.$fileClean); | ||
| 145 | return Response::json( $response, $statusCode); | 146 | return Response::json( $response, $statusCode); |
| 146 | 147 | ||
| 147 | 148 | ... | ... |
| 1 | <?php namespace App\Http\Controllers; | 1 | <?php namespace App\Http\Controllers; |
| 2 | 2 | ||
| 3 | use JWTAuth; | 3 | use JWTAuth; |
| 4 | use Tymon\JWTAuth\Exceptions\JWTException; | 4 | //use Tymon\JWTAuth\Exceptions\JWTException; |
| 5 | use Illuminate\Http\Request; | 5 | use Illuminate\Http\Request; |
| 6 | use App\User; | 6 | use App\User; |
| 7 | 7 | ... | ... |
| 1 | <?php | ||
| 2 | |||
| 3 | namespace App\Http\Controllers; | ||
| 4 | |||
| 5 | use Illuminate\Http\Request; | ||
| 6 | use App\Http\Requests; | ||
| 7 | use App\Http\Controllers; | ||
| 8 | use App\pdfModel; | ||
| 9 | use URL; | ||
| 10 | use Storage; | ||
| 11 | use Response; | ||
| 12 | use File; | ||
| 13 | Use PDF; | ||
| 14 | use Illuminate\Support\Facades\Input; | ||
| 15 | use Intervention\Image\Facades\Image; | ||
| 16 | use Illuminate\Support\Facades\Facade; | ||
| 17 | use League\Flysystem\Filesystem; | ||
| 18 | use Curl\Curl; | ||
| 19 | use Google_Client; | ||
| 20 | use Google_Service_Drive; | ||
| 21 | |||
| 22 | |||
| 23 | use Imagick; | ||
| 24 | |||
| 25 | |||
| 26 | |||
| 27 | |||
| 28 | |||
| 29 | |||
| 30 | |||
| 31 | |||
| 32 | |||
| 33 | |||
| 34 | |||
| 35 | class GoogledriveuploadpdfController extends Controller | ||
| 36 | { | ||
| 37 | |||
| 38 | public function google_drive_upload($folder, $filename) | ||
| 39 | { | ||
| 40 | |||
| 41 | $pdffile = new FileEntryController(); | ||
| 42 | $pdfFile = $pdffile->getPDF($folder, $filename); | ||
| 43 | |||
| 44 | |||
| 45 | $client = new \Google_Client(); | ||
| 46 | |||
| 47 | |||
| 48 | $client->setScopes(array('https://www.googleapis.com/auth/drive.file')); | ||
| 49 | $client->setClientId('2147483647'); | ||
| 50 | $client->setClientSecret('qmUMAi09SU4wU4R3uOkvsiwK'); | ||
| 51 | $client->setRedirectUri('http://pdf-customizer.synapsus.co/auth/google/callback'); | ||
| 52 | |||
| 53 | |||
| 54 | |||
| 55 | |||
| 56 | |||
| 57 | $dr_service = new \Google_Service_Drive($client); | ||
| 58 | $file = new \Google_Service_Drive_DriveFile(); | ||
| 59 | |||
| 60 | |||
| 61 | $mimetype = 'application/pdf'; | ||
| 62 | $uploadType = 'media'; | ||
| 63 | $filetitle = $filename; | ||
| 64 | //$filedescription = 'Taskew ' . $model['discussion_title']; | ||
| 65 | |||
| 66 | $datetime = date('d-m-y-h:s'); | ||
| 67 | |||
| 68 | $file->setTitle($datetime . $filetitle); | ||
| 69 | //$file->setDescription($filedescription); | ||
| 70 | $file->setMimeType($mimetype); | ||
| 71 | |||
| 72 | $data = $pdfFile; | ||
| 73 | |||
| 74 | $createdFile = $dr_service->files->insert($file, array( | ||
| 75 | 'data' => $data, | ||
| 76 | 'mimeType' => $mimetype, //text/plain', | ||
| 77 | 'uploadType' => $uploadType | ||
| 78 | )); | ||
| 79 | |||
| 80 | |||
| 81 | |||
| 82 | |||
| 83 | |||
| 84 | |||
| 85 | } | ||
| 86 | |||
| 87 | public function handleProviderCallback() | ||
| 88 | { | ||
| 89 | |||
| 90 | |||
| 91 | return Redirect::to('home'); | ||
| 92 | } | ||
| 93 | } | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| ... | @@ -51,3 +51,6 @@ Route::get('fileentry/getPDF/{folder}/{filename}', 'FileEntryController@getPDF' | ... | @@ -51,3 +51,6 @@ Route::get('fileentry/getPDF/{folder}/{filename}', 'FileEntryController@getPDF' |
| 51 | 51 | ||
| 52 | Route::post('fileentry/add',[ | 52 | Route::post('fileentry/add',[ |
| 53 | 'as' => 'addentry', 'uses' => 'FileEntryController@add']); | 53 | 'as' => 'addentry', 'uses' => 'FileEntryController@add']); |
| 54 | |||
| 55 | Route::get('api/googlePdfUpload/{folder}/{filename}', 'GoogledriveuploadpdfController@google_drive_upload'); | ||
| 56 | Route::get('auth/google/callback', 'GoogledriveuploadpdfController@handleGoogleCallback'); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -12,10 +12,11 @@ | ... | @@ -12,10 +12,11 @@ |
| 12 | "barryvdh/laravel-snappy": "^0.3.0", | 12 | "barryvdh/laravel-snappy": "^0.3.0", |
| 13 | "vsmoraes/laravel-pdf": "^1.0", | 13 | "vsmoraes/laravel-pdf": "^1.0", |
| 14 | "php-curl-class/php-curl-class": "^4.11", | 14 | "php-curl-class/php-curl-class": "^4.11", |
| 15 | "ext-PDO": "^7.0", | 15 | |
| 16 | "ext-pdo_pgsql": "^7.0", | ||
| 17 | "slim/pdo": "^1.9", | 16 | "slim/pdo": "^1.9", |
| 18 | "doctrine/dbal": "^2.5" | 17 | "doctrine/dbal": "^2.5", |
| 18 | "tymon/jwt-auth": "^0.5.9", | ||
| 19 | "google/apiclient": "1.1.1" | ||
| 19 | 20 | ||
| 20 | 21 | ||
| 21 | }, | 22 | }, | ... | ... |
| ... | @@ -4,8 +4,8 @@ | ... | @@ -4,8 +4,8 @@ |
| 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", | 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", |
| 5 | "This file is @generated automatically" | 5 | "This file is @generated automatically" |
| 6 | ], | 6 | ], |
| 7 | "hash": "bd5acf06527a71243b4914e1b34144ac", | 7 | "hash": "987cf4cbb0eb835825ebafb157a36f30", |
| 8 | "content-hash": "e5b082b079774eaef01edacb786fcf23", | 8 | "content-hash": "7a41d7f13395ea0a3d0ae6e2c9c2d8f7", |
| 9 | "packages": [ | 9 | "packages": [ |
| 10 | { | 10 | { |
| 11 | "name": "barryvdh/laravel-snappy", | 11 | "name": "barryvdh/laravel-snappy", |
| ... | @@ -657,6 +657,48 @@ | ... | @@ -657,6 +657,48 @@ |
| 657 | "time": "2015-12-07 04:07:13" | 657 | "time": "2015-12-07 04:07:13" |
| 658 | }, | 658 | }, |
| 659 | { | 659 | { |
| 660 | "name": "google/apiclient", | ||
| 661 | "version": "1.1.1", | ||
| 662 | "source": { | ||
| 663 | "type": "git", | ||
| 664 | "url": "https://github.com/google/google-api-php-client.git", | ||
| 665 | "reference": "f985b38158efe4c55c90b90443311f792c919a59" | ||
| 666 | }, | ||
| 667 | "dist": { | ||
| 668 | "type": "zip", | ||
| 669 | "url": "https://api.github.com/repos/google/google-api-php-client/zipball/f985b38158efe4c55c90b90443311f792c919a59", | ||
| 670 | "reference": "f985b38158efe4c55c90b90443311f792c919a59", | ||
| 671 | "shasum": "" | ||
| 672 | }, | ||
| 673 | "require": { | ||
| 674 | "php": ">=5.2.1" | ||
| 675 | }, | ||
| 676 | "require-dev": { | ||
| 677 | "phpunit/phpunit": "3.7.*" | ||
| 678 | }, | ||
| 679 | "type": "library", | ||
| 680 | "extra": { | ||
| 681 | "branch-alias": { | ||
| 682 | "dev-master": "1.1.x-dev" | ||
| 683 | } | ||
| 684 | }, | ||
| 685 | "autoload": { | ||
| 686 | "classmap": [ | ||
| 687 | "src/" | ||
| 688 | ] | ||
| 689 | }, | ||
| 690 | "notification-url": "https://packagist.org/downloads/", | ||
| 691 | "license": [ | ||
| 692 | "Apache-2.0" | ||
| 693 | ], | ||
| 694 | "description": "Client library for Google APIs", | ||
| 695 | "homepage": "http://developers.google.com/api-client-library/php", | ||
| 696 | "keywords": [ | ||
| 697 | "google" | ||
| 698 | ], | ||
| 699 | "time": "2014-11-20 10:13:43" | ||
| 700 | }, | ||
| 701 | { | ||
| 660 | "name": "itbz/fpdf", | 702 | "name": "itbz/fpdf", |
| 661 | "version": "1.7.2", | 703 | "version": "1.7.2", |
| 662 | "source": { | 704 | "source": { |
| ... | @@ -1231,6 +1273,56 @@ | ... | @@ -1231,6 +1273,56 @@ |
| 1231 | "time": "2016-01-26 21:23:30" | 1273 | "time": "2016-01-26 21:23:30" |
| 1232 | }, | 1274 | }, |
| 1233 | { | 1275 | { |
| 1276 | "name": "namshi/jose", | ||
| 1277 | "version": "5.0.2", | ||
| 1278 | "source": { | ||
| 1279 | "type": "git", | ||
| 1280 | "url": "https://github.com/namshi/jose.git", | ||
| 1281 | "reference": "8c7eba486f74c014ea1d8faedafe5109a31ea95b" | ||
| 1282 | }, | ||
| 1283 | "dist": { | ||
| 1284 | "type": "zip", | ||
| 1285 | "url": "https://api.github.com/repos/namshi/jose/zipball/8c7eba486f74c014ea1d8faedafe5109a31ea95b", | ||
| 1286 | "reference": "8c7eba486f74c014ea1d8faedafe5109a31ea95b", | ||
| 1287 | "shasum": "" | ||
| 1288 | }, | ||
| 1289 | "require": { | ||
| 1290 | "lib-openssl": "*", | ||
| 1291 | "php": ">=5.3.3", | ||
| 1292 | "phpseclib/phpseclib": "~0.3" | ||
| 1293 | }, | ||
| 1294 | "require-dev": { | ||
| 1295 | "phpunit/phpunit": "~4.5", | ||
| 1296 | "satooshi/php-coveralls": "dev-master" | ||
| 1297 | }, | ||
| 1298 | "type": "library", | ||
| 1299 | "autoload": { | ||
| 1300 | "psr-0": { | ||
| 1301 | "Namshi\\JOSE": "src/" | ||
| 1302 | } | ||
| 1303 | }, | ||
| 1304 | "notification-url": "https://packagist.org/downloads/", | ||
| 1305 | "license": [ | ||
| 1306 | "MIT" | ||
| 1307 | ], | ||
| 1308 | "authors": [ | ||
| 1309 | { | ||
| 1310 | "name": "Alessandro Nadalin", | ||
| 1311 | "email": "alessandro.nadalin@gmail.com" | ||
| 1312 | } | ||
| 1313 | ], | ||
| 1314 | "description": "JSON Object Signing and Encryption library for PHP.", | ||
| 1315 | "keywords": [ | ||
| 1316 | "JSON Web Signature", | ||
| 1317 | "JSON Web Token", | ||
| 1318 | "JWS", | ||
| 1319 | "json", | ||
| 1320 | "jwt", | ||
| 1321 | "token" | ||
| 1322 | ], | ||
| 1323 | "time": "2015-06-29 05:41:44" | ||
| 1324 | }, | ||
| 1325 | { | ||
| 1234 | "name": "nesbot/carbon", | 1326 | "name": "nesbot/carbon", |
| 1235 | "version": "1.21.0", | 1327 | "version": "1.21.0", |
| 1236 | "source": { | 1328 | "source": { |
| ... | @@ -1467,6 +1559,104 @@ | ... | @@ -1467,6 +1559,104 @@ |
| 1467 | "time": "2016-03-09 00:50:07" | 1559 | "time": "2016-03-09 00:50:07" |
| 1468 | }, | 1560 | }, |
| 1469 | { | 1561 | { |
| 1562 | "name": "phpseclib/phpseclib", | ||
| 1563 | "version": "0.3.10", | ||
| 1564 | "source": { | ||
| 1565 | "type": "git", | ||
| 1566 | "url": "https://github.com/phpseclib/phpseclib.git", | ||
| 1567 | "reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4" | ||
| 1568 | }, | ||
| 1569 | "dist": { | ||
| 1570 | "type": "zip", | ||
| 1571 | "url": "https://api.github.com/repos/phpseclib/phpseclib/zipball/d15bba1edcc7c89e09cc74c5d961317a8b947bf4", | ||
| 1572 | "reference": "d15bba1edcc7c89e09cc74c5d961317a8b947bf4", | ||
| 1573 | "shasum": "" | ||
| 1574 | }, | ||
| 1575 | "require": { | ||
| 1576 | "php": ">=5.0.0" | ||
| 1577 | }, | ||
| 1578 | "require-dev": { | ||
| 1579 | "phing/phing": "~2.7", | ||
| 1580 | "phpunit/phpunit": "~4.0", | ||
| 1581 | "sami/sami": "~2.0", | ||
| 1582 | "squizlabs/php_codesniffer": "~1.5" | ||
| 1583 | }, | ||
| 1584 | "suggest": { | ||
| 1585 | "ext-gmp": "Install the GMP (GNU Multiple Precision) extension in order to speed up arbitrary precision integer arithmetic operations.", | ||
| 1586 | "ext-mcrypt": "Install the Mcrypt extension in order to speed up a wide variety of cryptographic operations.", | ||
| 1587 | "pear-pear/PHP_Compat": "Install PHP_Compat to get phpseclib working on PHP < 4.3.3." | ||
| 1588 | }, | ||
| 1589 | "type": "library", | ||
| 1590 | "extra": { | ||
| 1591 | "branch-alias": { | ||
| 1592 | "dev-master": "0.3-dev" | ||
| 1593 | } | ||
| 1594 | }, | ||
| 1595 | "autoload": { | ||
| 1596 | "psr-0": { | ||
| 1597 | "Crypt": "phpseclib/", | ||
| 1598 | "File": "phpseclib/", | ||
| 1599 | "Math": "phpseclib/", | ||
| 1600 | "Net": "phpseclib/", | ||
| 1601 | "System": "phpseclib/" | ||
| 1602 | }, | ||
| 1603 | "files": [ | ||
| 1604 | "phpseclib/Crypt/Random.php" | ||
| 1605 | ] | ||
| 1606 | }, | ||
| 1607 | "notification-url": "https://packagist.org/downloads/", | ||
| 1608 | "include-path": [ | ||
| 1609 | "phpseclib/" | ||
| 1610 | ], | ||
| 1611 | "license": [ | ||
| 1612 | "MIT" | ||
| 1613 | ], | ||
| 1614 | "authors": [ | ||
| 1615 | { | ||
| 1616 | "name": "Jim Wigginton", | ||
| 1617 | "email": "terrafrost@php.net", | ||
| 1618 | "role": "Lead Developer" | ||
| 1619 | }, | ||
| 1620 | { | ||
| 1621 | "name": "Patrick Monnerat", | ||
| 1622 | "email": "pm@datasphere.ch", | ||
| 1623 | "role": "Developer" | ||
| 1624 | }, | ||
| 1625 | { | ||
| 1626 | "name": "Andreas Fischer", | ||
| 1627 | "email": "bantu@phpbb.com", | ||
| 1628 | "role": "Developer" | ||
| 1629 | }, | ||
| 1630 | { | ||
| 1631 | "name": "Hans-Jürgen Petrich", | ||
| 1632 | "email": "petrich@tronic-media.com", | ||
| 1633 | "role": "Developer" | ||
| 1634 | } | ||
| 1635 | ], | ||
| 1636 | "description": "PHP Secure Communications Library - Pure-PHP implementations of RSA, AES, SSH2, SFTP, X.509 etc.", | ||
| 1637 | "homepage": "http://phpseclib.sourceforge.net", | ||
| 1638 | "keywords": [ | ||
| 1639 | "BigInteger", | ||
| 1640 | "aes", | ||
| 1641 | "asn.1", | ||
| 1642 | "asn1", | ||
| 1643 | "blowfish", | ||
| 1644 | "crypto", | ||
| 1645 | "cryptography", | ||
| 1646 | "encryption", | ||
| 1647 | "rsa", | ||
| 1648 | "security", | ||
| 1649 | "sftp", | ||
| 1650 | "signature", | ||
| 1651 | "signing", | ||
| 1652 | "ssh", | ||
| 1653 | "twofish", | ||
| 1654 | "x.509", | ||
| 1655 | "x509" | ||
| 1656 | ], | ||
| 1657 | "time": "2015-01-28 21:50:33" | ||
| 1658 | }, | ||
| 1659 | { | ||
| 1470 | "name": "psr/log", | 1660 | "name": "psr/log", |
| 1471 | "version": "1.0.0", | 1661 | "version": "1.0.0", |
| 1472 | "source": { | 1662 | "source": { |
| ... | @@ -2455,6 +2645,69 @@ | ... | @@ -2455,6 +2645,69 @@ |
| 2455 | "time": "2016-03-10 10:34:12" | 2645 | "time": "2016-03-10 10:34:12" |
| 2456 | }, | 2646 | }, |
| 2457 | { | 2647 | { |
| 2648 | "name": "tymon/jwt-auth", | ||
| 2649 | "version": "0.5.9", | ||
| 2650 | "source": { | ||
| 2651 | "type": "git", | ||
| 2652 | "url": "https://github.com/tymondesigns/jwt-auth.git", | ||
| 2653 | "reference": "18b2add90de2315d549664b4d4a062db07e8b080" | ||
| 2654 | }, | ||
| 2655 | "dist": { | ||
| 2656 | "type": "zip", | ||
| 2657 | "url": "https://api.github.com/repos/tymondesigns/jwt-auth/zipball/18b2add90de2315d549664b4d4a062db07e8b080", | ||
| 2658 | "reference": "18b2add90de2315d549664b4d4a062db07e8b080", | ||
| 2659 | "shasum": "" | ||
| 2660 | }, | ||
| 2661 | "require": { | ||
| 2662 | "illuminate/http": "~5.0", | ||
| 2663 | "illuminate/support": "~5.0", | ||
| 2664 | "namshi/jose": "5.0.*", | ||
| 2665 | "nesbot/carbon": "~1.0", | ||
| 2666 | "php": ">=5.4.0" | ||
| 2667 | }, | ||
| 2668 | "require-dev": { | ||
| 2669 | "illuminate/auth": "~5.0", | ||
| 2670 | "illuminate/console": "~5.0", | ||
| 2671 | "illuminate/database": "~5.0", | ||
| 2672 | "mockery/mockery": "0.9.*", | ||
| 2673 | "phpunit/phpunit": "4.*" | ||
| 2674 | }, | ||
| 2675 | "type": "library", | ||
| 2676 | "extra": { | ||
| 2677 | "branch-alias": { | ||
| 2678 | "dev-develop": "0.5-dev" | ||
| 2679 | } | ||
| 2680 | }, | ||
| 2681 | "autoload": { | ||
| 2682 | "psr-4": { | ||
| 2683 | "Tymon\\JWTAuth\\": "src" | ||
| 2684 | } | ||
| 2685 | }, | ||
| 2686 | "notification-url": "https://packagist.org/downloads/", | ||
| 2687 | "license": [ | ||
| 2688 | "MIT" | ||
| 2689 | ], | ||
| 2690 | "authors": [ | ||
| 2691 | { | ||
| 2692 | "name": "Sean Tymon", | ||
| 2693 | "email": "tymon148@gmail.com", | ||
| 2694 | "homepage": "http://tymondesigns.com", | ||
| 2695 | "role": "Developer" | ||
| 2696 | } | ||
| 2697 | ], | ||
| 2698 | "description": "JSON Web Token Authentication for Laravel 4 and 5", | ||
| 2699 | "homepage": "https://github.com/tymondesigns/jwt-auth", | ||
| 2700 | "keywords": [ | ||
| 2701 | "Authentication", | ||
| 2702 | "JSON Web Token", | ||
| 2703 | "auth", | ||
| 2704 | "jwt", | ||
| 2705 | "laravel", | ||
| 2706 | "tymon" | ||
| 2707 | ], | ||
| 2708 | "time": "2016-02-18 09:22:36" | ||
| 2709 | }, | ||
| 2710 | { | ||
| 2458 | "name": "vlucas/phpdotenv", | 2711 | "name": "vlucas/phpdotenv", |
| 2459 | "version": "v2.2.0", | 2712 | "version": "v2.2.0", |
| 2460 | "source": { | 2713 | "source": { |
| ... | @@ -3871,9 +4124,7 @@ | ... | @@ -3871,9 +4124,7 @@ |
| 3871 | "prefer-stable": false, | 4124 | "prefer-stable": false, |
| 3872 | "prefer-lowest": false, | 4125 | "prefer-lowest": false, |
| 3873 | "platform": { | 4126 | "platform": { |
| 3874 | "php": ">=5.5.9", | 4127 | "php": ">=5.5.9" |
| 3875 | "ext-pdo": "^7.0", | ||
| 3876 | "ext-pdo_pgsql": "^7.0" | ||
| 3877 | }, | 4128 | }, |
| 3878 | "platform-dev": [] | 4129 | "platform-dev": [] |
| 3879 | } | 4130 | } | ... | ... |
-
Please register or sign in to post a comment