public function testFacadeCanBeResolvedToServiceInstance() { $app = $this->setupApplication(); $this->setupServiceProvider($app); // Mount facades AWS::setFacadeApplication($app); // Get an instance of a client (S3) via its facade $s3 = AWS::get('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::get('s3'); $s3->putObject(['Bucket' => $bucket, 'Key' => $this->getS3DumpsPath() . '/' . $this->fileName, 'SourceFile' => $this->filePath]); }
/** * @group basic * @group upload-test */ public function test_uploads_can_have_an_existing_series_id() { $this->seed(); Storage::shouldReceive('disk->put'); AWS::shouldReceive('createClient->getCommand'); AWS::shouldReceive('createClient->createPresignedRequest->getUri'); AWS::shouldReceive('createClient->getObjectUrl')->andReturn('value'); AWS::shouldReceive('Lambda'); AWS::shouldReceive('Lambda->invokeAsync'); $series = factory(App\Models\Series::class)->create(['user_id' => 1]); $file = new Symfony\Component\HttpFoundation\File\UploadedFile(storage_path('test files/test-comic-6-pages.cbz'), 'test-comic-6-pages.cbz', 'application/zip', 1000, null, TRUE); $req = $this->postWithFile($this->basic_upload_endpoint, ["series_id" => $series->id, "comic_id" => Uuid::uuid4()->toString(), "series_title" => "test", "series_start_year" => "2015", "comic_issue" => 1], ['Authorization' => 'Bearer ' . $this->test_basic_access_token], ['file' => $file]); $this->assertResponseStatus(201); }