public function testFacadeCanBeResolvedToServiceInstance() { $app = $this->setupApplication(); $this->setupServiceProvider($app); // Mount facades AWS::setFacadeApplication($app); // Get an instance of a client (S3) via the facade. $s3 = AWS::createClient('S3'); $this->assertInstanceOf('Aws\\S3\\S3Client', $s3); }
function getFileUrl($driver, $file, $expiry = 0) { //Supported: "local", "s3", "rackspace" if ($driver == "s3") { $client = AWS::createClient('s3'); if ($expiry) { $command = $client->getCommand('GetObject', ['Bucket' => env('S3_USER_UPLOADS_BUCKET'), 'Key' => $file]); $request = $client->createPresignedRequest($command, '+10 minutes'); $plainUrl = $presignedUrl = (string) $request->getUri(); } else { $plainUrl = $client->getObjectUrl(env('S3_USER_UPLOADS_BUCKET'), $file); } } else { if ($driver == "rackspace") { } else { dd("Not Supported"); //TODO: Throw HTTP Exception } } return $plainUrl; }
/** * @return void */ protected function uploadS3() { $bucket = $this->option('upload-s3'); $s3 = AWS::createClient('s3'); $s3->putObject(['Bucket' => $bucket, 'Key' => $this->getS3DumpsPath() . '/' . $this->fileName, 'SourceFile' => $this->filePath]); }