The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
update upload docs
Inianb02a709631c0
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.tsindex 64e1d406626..d065508cbaa 100644--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts@@ -674,7 +674,7 @@ export const storage = {items: [{ name: 'Overview', url: '/guides/storage' },{ name: 'Quickstart', url: '/guides/storage/quickstart' },- { name: 'Uploads', url: '/guides/storage/uploading' },+ { name: 'Uploads', url: '/guides/storage/uploads' },{ name: 'Access Control', url: '/guides/storage/access-control' },{ name: 'CDN', url: '/guides/storage/cdn' },{ name: 'Image Transformations', url: '/guides/storage/image-transformations' },diff --git a/apps/docs/pages/guides/storage/uploading.mdx b/apps/docs/pages/guides/storage/uploading.mdxdeleted file mode 100644index ab027548693..00000000000--- a/apps/docs/pages/guides/storage/uploading.mdx+++ /dev/null@@ -1,135 +0,0 @@-import Layout from '~/layouts/DefaultGuideLayout'--export const meta = {- id: 'storage-uploads',- title: 'Storage Uploads',- description: 'Learn how to upload files to Supabase Storage.',- sidebar_label: 'Uploads',-}---Supabase Storage provides two methods for uploading files:-- Standard multi-part/form-- Resuamble Uploads--## Standard Upload--The standard file upload method is ideal for small files that are not larger than 6MB.--It uses the traditional multi-part/form data format and is simple to implement using the supabase-js SDK. Here's an example of how to upload a file using the standard upload method:--<Admonition type="note">- You can upload up to 5GB file size using the standard upload method.<br />- For larger files, use [TUS Resumable Upload](#tus-resumable-upload).-</Admonition>--```javascript-import { createClient } from '@supabase/supabase-js';--// Create Supabase client-const supabase = createClient('your_project_url', 'your_supabase_api_key');--// Upload file using standard upload-async function uploadFile(file) {- const { data, error } = await supabase.storage.from('bucket_name').upload('file_path', file);- if (error) {- // Handle error- } else {- // Handle success- }-}-```--## Resumable Upload---<Admonition type="note">-Resumable upload is in **Beta**.--It might not be available immediately for your project in your region. <br />-We are rolling this feature gradually, Please contact us if you want to be prioritised.-</Admonition>--The Resumable upload method is recommended for uploading large files that may exceed 6MB in size or for scenarios where network stability may be a concern.--Supabase Storage implements the TUS protocol to enable resumable uploads, allowing the upload process to be resumed from where it left off in case of interruptions.-This method can be implemented using the tus-js-client library, or other client-side libraries like [Uppy-js](https://uppy.io/docs/tus/) that support the TUS protocol.--Here's an example of how to upload a file using `tus-js-client`:--```javascript-const tus = require('tus-js-client');--const projectId = ''-const token = ''--function uploadFile(bucketName, fileName, file) {- return new Promise((resolve, reject) => {- var upload = new tus.Upload(file, {- endpoint: `https://${projectId}.supabase.co/storage/v1/upload/resumable`,- retryDelays: [0, 3000, 5000, 10000, 20000],- headers: {- authorization: `Bearer ${token}`,- 'x-upsert': 'true', // optionally set upsert to true to overwrite existing files- },- uploadDataDuringCreation: true,- metadata: {- bucketName: bucketName,- objectName: fileName,- contentType: 'image/png',- cacheControl: 3600,- },- chunkSize: 6 * 1024 * 1024, // NOTE: it must be set to 6MB (for now) do not change it- onError: function(error) {- console.log("Failed because: " + error)- reject(error)- },- onProgress: function(bytesUploaded, bytesTotal) {- var percentage = (bytesUploaded / bytesTotal * 100).toFixed(2)- console.log(bytesUploaded, bytesTotal, percentage + "%")- },- onSuccess: function() {- // console.log(upload)- console.log("Download %s from %s", upload.file.name, upload.url)- resolve()- }- })-- // Check if there are any previous uploads to continue.- return upload.findPreviousUploads().then(function (previousUploads) {- // Found previous uploads so we select the first one.- if (previousUploads.length) {- upload.resumeFromPreviousUpload(previousUploads[0])- }-- // Start the upload- upload.start()- })- })-}-```--### UppyJS Example--You can check a full example using UppyJS [Here](https://github.com/supabase/supabase/tree/master/examples/storage/resumable-upload-uppy)--Framework integration for UppyJS:--- [React](https://uppy.io/docs/react/)-- [Svelte](https://uppy.io/docs/svelte/)-- [Vue](https://uppy.io/docs/vue/)-- [Angular](https://uppy.io/docs/angular/)--## Access Control with RLS Policies-Both the standard file upload and TUS resumable file upload methods in Supabase Storage support Row-Level Security (RLS) policies. RLS allows you to define fine-grained access control rules to restrict access to files based on user roles, permissions, or other criteria. This ensures that your files are secure and accessible only to authorized users.--For more information on RLS policies, see the [Storage Access Control](/docs/guides/storage/access-control) guide.--## Conclusion-Supabase Storage provides multiple options for uploading files, including standard file upload and TUS resumable file upload, both of which support RLS policies for access control.-Additionally, there are client-side libraries like Uppy-js that make it easy to implement TUS uploads in your application. Choose the upload method that best fits your needs based on file size, network stability, and other requirements.---export const Page = ({ children }) => <Layout meta={meta} children={children} />--export default Pagediff --git a/apps/docs/pages/guides/storage/uploads.mdx b/apps/docs/pages/guides/storage/uploads.mdxnew file mode 100644index 00000000000..a569ef5c088--- /dev/null+++ b/apps/docs/pages/guides/storage/uploads.mdx@@ -0,0 +1,137 @@+import Layout from '~/layouts/DefaultGuideLayout'++export const meta = {+ id: 'storage-uploads',+ title: 'Storage Uploads',+ description: 'Learn how to upload files to Supabase Storage.',+ sidebar_label: 'Uploads',+}++Supabase Storage provides two methods for uploading files:++- Standard Uploads+- Resuamble Uploads++## Standard Upload++The standard file upload method is ideal for small files that are not larger than 6MB.++It uses the traditional `multipart/form-data` format and is simple to implement using the supabase-js SDK. Here's an example of how to upload a file using the standard upload method:++<Admonition type="note">+ You can upload up to 5GB file size using the standard upload method.+ <br />+ For larger files, use [TUS Resumable Upload](#tus-resumable-upload).+</Admonition>++```javascript+import { createClient } from '@supabase/supabase-js'++// Create Supabase client+const supabase = createClient('your_project_url', 'your_supabase_api_key')++// Upload file using standard upload+async function uploadFile(file) {+ const { data, error } = await supabase.storage.from('bucket_name').upload('file_path', file)+ if (error) {+ // Handle error+ } else {+ // Handle success+ }+}+```++## Resumable Upload++<Admonition type="note">+Resumable upload is in **Beta**.++It might not be available immediately for your project. <br />+We are rolling this feature gradually, please contact us if you want to be prioritised.++</Admonition>++The Resumable upload method is recommended for uploading large files that may exceed 6MB in size or for scenarios where network stability is a concern.++Supabase Storage implements the [TUS protocol](https://tus.io/) to enable resumable uploads. TUS stands for The Upload Server and is an open protocol for supporting resumable uploads. The protocol allows the upload process to be resumed from where it left off in case of interruptions.+This method can be implemented using the tus-js-client library, or other client-side libraries like [Uppy-js](https://uppy.io/docs/tus/) that support the TUS protocol.++Here's an example of how to upload a file using `tus-js-client`:++```javascript+const tus = require('tus-js-client')++const projectId = ''+const token = ''++function uploadFile(bucketName, fileName, file) {+ return new Promise((resolve, reject) => {+ var upload = new tus.Upload(file, {+ endpoint: `https://${projectId}.supabase.co/storage/v1/upload/resumable`,+ retryDelays: [0, 3000, 5000, 10000, 20000],+ headers: {+ authorization: `Bearer ${token}`,+ 'x-upsert': 'true', // optionally set upsert to true to overwrite existing files+ },+ uploadDataDuringCreation: true,+ metadata: {+ bucketName: bucketName,+ objectName: fileName,+ contentType: 'image/png',+ cacheControl: 3600,+ },+ chunkSize: 6 * 1024 * 1024, // NOTE: it must be set to 6MB (for now) do not change it+ onError: function (error) {+ console.log('Failed because: ' + error)+ reject(error)+ },+ onProgress: function (bytesUploaded, bytesTotal) {+ var percentage = ((bytesUploaded / bytesTotal) * 100).toFixed(2)+ console.log(bytesUploaded, bytesTotal, percentage + '%')+ },+ onSuccess: function () {+ // console.log(upload)+ console.log('Download %s from %s', upload.file.name, upload.url)+ resolve()+ },+ })++ // Check if there are any previous uploads to continue.+ return upload.findPreviousUploads().then(function (previousUploads) {+ // Found previous uploads so we select the first one.+ if (previousUploads.length) {+ upload.resumeFromPreviousUpload(previousUploads[0])+ }++ // Start the upload+ upload.start()+ })+ })+}+```++### UppyJS Example++You can check a full example using UppyJS [Here](https://github.com/supabase/supabase/tree/master/examples/storage/resumable-upload-uppy)++Framework integration for UppyJS:++- [React](https://uppy.io/docs/react/)+- [Svelte](https://uppy.io/docs/svelte/)+- [Vue](https://uppy.io/docs/vue/)+- [Angular](https://uppy.io/docs/angular/)++## Access Control with RLS Policies++Both the standard file upload and TUS resumable file upload methods in Supabase Storage support Row-Level Security (RLS) policies. RLS allows you to define fine-grained access control rules to restrict access to files based on user roles, permissions, or other criteria. This ensures that your files are secure and accessible only to authorized users.++For more information on RLS policies, see the [Storage Access Control](/docs/guides/storage/access-control) guide.++## Conclusion++Supabase Storage provides multiple options for uploading files, including standard file upload and TUS resumable file upload, both of which use RLS policies for access control.+Additionally, there are client-side libraries like Uppy-js that make it easy to implement TUS uploads in your application. Choose the upload method that best fits your needs based on file size, network stability, and other requirements.++export const Page = ({ children }) => <Layout meta={meta} children={children} />++export default Page