-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from zero-copy-labs/main
Improvements to examples
- Loading branch information
Showing
25 changed files
with
289 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageClient; | ||
|
||
$scheme = 'http'; | ||
$domain = 'localhost:3000'; | ||
$path = '/storage/v1'; | ||
$client = new StorageClient($api_key, $reference_id, $domain, $scheme, $path); | ||
$result = $client->createBucket('test-bucket-new', ['public' => false]); | ||
$output = json_decode($result->getBody(), true); | ||
//giving unique id to our bucket | ||
$testBucket = 'test-bucket'.uniqid(); | ||
|
||
//creating our client and passing API_KEY & REFERENCE_ID | ||
$client = new StorageClient($api_key, $reference_id); | ||
|
||
//Created a bucket and printing out thr result | ||
$result = $client->createBucket($testBucket, ['public' => false]); | ||
$output = json_decode($result->getBody(), true); | ||
print_r($output); | ||
|
||
//Deleting our examples | ||
$client->deleteBucket($testBucket); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,18 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageClient; | ||
|
||
//Creating unique ID | ||
$testBucket = 'test-bucket'.uniqid(); | ||
|
||
//Creating our client and passing API_KEY & REFERENCE_ID | ||
$client = new StorageClient($api_key, $reference_id); | ||
$result = $client->deleteBucket('test-bucket-new'); | ||
//Creating a bucket as example to test our remove method. | ||
$client->createBucket($testBucket, ['public' => false]); | ||
|
||
//Deleting a bucket function and printing result. | ||
$result = $client->deleteBucket($testBucket); | ||
$output = json_decode($result->getBody(), true); | ||
print_r($output); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,19 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageClient; | ||
|
||
//Creating out client to upload files | ||
$client = new StorageClient($api_key, $reference_id); | ||
$result = $client->emptyBucket('test-bucket'); | ||
//Assigning a unique ID to our bucket | ||
$testBucket = 'test-bucket'.uniqid(); | ||
//creating a bucket to upload files into | ||
$client->createBucket($testBucket, ['public' => false]); | ||
//We will empty out our bucket with the following function and print our the response. | ||
$result = $client->emptyBucket($testBucket); | ||
$output = json_decode($result->getBody(), true); | ||
print_r($output); | ||
|
||
//Delete the example bucket | ||
$client->deleteBucket($testBucket); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageClient; | ||
|
||
//Crete a client. | ||
$client = new StorageClient($api_key, $reference_id); | ||
$result = $client->getBucket('test-bucket'); | ||
//Creating a bucket with a unique ID. | ||
$testBucket = 'test-bucket'.uniqid(); | ||
$client->createBucket($testBucket, ['public' => false]); | ||
//Method to get a bucket, and print out result. | ||
$result = $client->getBucket($testBucket); | ||
$output = json_decode($result->getBody(), true); | ||
print_r($output); | ||
//Deleting example bucket | ||
$client->deleteBucket($testBucket); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,17 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageClient; | ||
|
||
$scheme = 'http'; | ||
$domain = 'localhost:8000'; | ||
$path = '/storage/v1'; | ||
//Crete a client. | ||
$client = new StorageClient($api_key, $reference_id); | ||
//Creating a bucket with a unique ID. | ||
$testBucket = 'test-bucket'.uniqid(); | ||
$client->createBucket($testBucket, ['public' => false]); | ||
//Method to list all buckets, and print out result. | ||
$result = $client->listBuckets(); | ||
$output = json_decode($result->getBody(), true); | ||
print_r($output); | ||
//Deleting example bucket | ||
$client->deleteBucket($testBucket); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageClient; | ||
|
||
$client = new StorageClient($api_key, $reference_id); | ||
$result = $client->updateBucket('test-bucket', ['public' => true]); | ||
//Crete a client. | ||
$client = new StorageClient($api_key, $reference_id); | ||
//Creating a bucket with a unique ID. | ||
$testBucket = 'test-bucket'.uniqid(); | ||
$client->createBucket($testBucket, ['public' => false]); | ||
//Method to update a bucket, and print out result. | ||
$result = $client->updateBucket($testBucket, ['public' => true]); | ||
$output = json_decode($result->getBody(), true); | ||
print_r($output); | ||
//Deleting example bucket | ||
$client->deleteBucket($testBucket); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 13 additions & 4 deletions
17
examples/handling-files/create-signed-url-file-which-triggers-download.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageFile; | ||
|
||
//Selecting an already created bucket for our test. | ||
$bucket_id = 'test-bucket'; | ||
|
||
$client = new StorageFile($api_key, $reference_id, $bucket_id); | ||
//Creating file with unique ID. | ||
$testFile = 'file'.uniqid().'.png'; | ||
//Creating our StorageFile instance to upload files. | ||
$file = new StorageFile($api_key, $reference_id, $bucket_id); | ||
//We will upload a test file to retrieve the URL. | ||
$file->upload($testFile, 'https://gpdefvsxamnscceccczu.supabase.co/storage/v1/object/public/examples-bucket/supabase-logo.png', ['public' => false]); | ||
//print out the URL of the examples file. | ||
$options = ['download' => true]; | ||
$result = $client->createSignedUrl('path/to/file-base64.png', 60, $options); | ||
print_r($result); | ||
$result = $file->createSignedUrl($testFile, 60, $options); | ||
print_r($result->getBody()->getContents()); | ||
//delete example files. | ||
$file->remove(["$testFile"]); |
19 changes: 14 additions & 5 deletions
19
examples/handling-files/create-signed-url-file-with-transformations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,20 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageFile; | ||
|
||
//Selecting an already created bucket for our test. | ||
$bucket_id = 'test-bucket'; | ||
|
||
$client = new StorageFile($api_key, $reference_id, $bucket_id); | ||
$options = ['transform' => ['width'=> '100', 'height'=> '100']]; | ||
$result = $client->createSignedUrl('path/to/file-base64.png', 60, $options); | ||
print_r($result); | ||
//Creating file with unique ID. | ||
$testFile = 'file'.uniqid().'.png'; | ||
//Creating our StorageFile instance to upload files. | ||
$file = new StorageFile($api_key, $reference_id, $bucket_id); | ||
//We will upload a test file to retrieve the URL. | ||
$file->upload($testFile, 'https://gpdefvsxamnscceccczu.supabase.co/storage/v1/object/public/examples-bucket/supabase-logo.png', ['public' => false]); | ||
//print out the URL of the examples file. | ||
$options = ['transform' => ['width' => '100', 'height' => '100']]; | ||
$result = $file->createSignedUrl($testFile, 60, $options); | ||
print_r($result->getBody()->getContents()); | ||
//delete example files. | ||
$file->remove(["$testFile"]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
examples/handling-files/download-file-with-transformations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageFile; | ||
|
||
//Selecting an already created bucket for our test. | ||
$bucket_id = 'test-bucket'; | ||
//Also creating file with unique ID. | ||
$testFile = 'file'.uniqid().'.png'; | ||
//Creating our StorageFile instance to upload files. | ||
$file = new StorageFile($api_key, $reference_id, $bucket_id); | ||
//We will upload a test file. | ||
$file->upload($testFile, 'https://gpdefvsxamnscceccczu.supabase.co/storage/v1/object/public/examples-bucket/supabase-logo.png', ['public' => false]); | ||
//print out result and download the file to our directory. | ||
$result = $file->download($testFile, ['transform' => ['width' => 50, 'height' => 50]]); | ||
$output = $result->getBody()->getContents(); | ||
file_put_contents('file.png', $output); | ||
//delete example files. | ||
$file->remove(["$testFile"]); |
13 changes: 0 additions & 13 deletions
13
examples/handling-files/download-file-with-transformatios.php
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,20 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageFile; | ||
|
||
//Selecting an already created bucket for our test. | ||
$bucket_id = 'test-bucket'; | ||
|
||
$client = new StorageFile($api_key, $reference_id, $bucket_id); | ||
$result = $client->download('path/to/file.png'); | ||
//Also creating file with unique ID. | ||
$testFile = 'file'.uniqid().'.png'; | ||
//Creating our StorageFile instance to upload files. | ||
$file = new StorageFile($api_key, $reference_id, $bucket_id); | ||
//We will upload a test file. | ||
$file->upload($testFile, 'https://gpdefvsxamnscceccczu.supabase.co/storage/v1/object/public/examples-bucket/supabase-logo.png', ['public' => false]); | ||
//we will download the file to our directory using the download method. | ||
$result = $file->download($testFile); | ||
$output = $result->getBody()->getContents(); | ||
file_put_contents('file.png', $output); | ||
print_r($output); | ||
//delete example files. | ||
$file->remove(["$testFile"]); |
16 changes: 12 additions & 4 deletions
16
examples/handling-files/get-public-url-file-with-transformations.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageFile; | ||
|
||
//Selecting an already created bucket for our test. | ||
$bucket_id = 'test-bucket'; | ||
|
||
$client = new StorageFile($api_key, $reference_id, $bucket_id); | ||
$options = ['transform' => ['width'=> 50, 'height'=> 50]]; | ||
$result = $client->getPublicUrl('path/to/file-base64.png', $options); | ||
//Also creating file with unique ID. | ||
$testFile = 'file'.uniqid().'.png'; | ||
//Creating our StorageFile instance to upload files. | ||
$file = new StorageFile($api_key, $reference_id, $bucket_id); | ||
//We will upload a test file to retrieve the URL. | ||
$file->upload($testFile, 'https://gpdefvsxamnscceccczu.supabase.co/storage/v1/object/public/examples-bucket/supabase-logo.png', ['public' => false]); | ||
//print out the URL of the examples file. | ||
$result = $file->getPublicUrl($testFile, ['transform' => ['width' => 50, 'height' => 50]]); | ||
print_r($result); | ||
//delete example files. Comment out the file->remove to be able to download the file from the browser. | ||
$file->remove(["$testFile"]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,19 @@ | ||
<?php | ||
|
||
include __DIR__.'/../header.php'; | ||
|
||
use Supabase\Storage\StorageFile; | ||
|
||
//Selecting an already created bucket for our test. | ||
$bucket_id = 'test-bucket'; | ||
|
||
$client = new StorageFile($api_key, $reference_id, $bucket_id); | ||
$options = ['download' => true]; | ||
$result = $client->getPublicUrl('path/to/file.png', $options); | ||
//Also creating file with unique ID. | ||
$testFile = 'file'.uniqid().'.png'; | ||
//Creating our StorageFile instance to upload files. | ||
$file = new StorageFile($api_key, $reference_id, $bucket_id); | ||
//We will upload a test file to retrieve the URL. | ||
$file->upload($testFile, 'https://gpdefvsxamnscceccczu.supabase.co/storage/v1/object/public/examples-bucket/supabase-logo.png', ['public' => false]); | ||
//print out the URL of the examples file that will trigger a download. | ||
$result = $file->getPublicUrl($testFile, ['download' => true]); | ||
print_r($result); | ||
//delete example files. Comment out the file->remove to be able to download the file from the browser. | ||
$file->remove(["$testFile"]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.