Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

chore: Remove the download bucket object mutation (#40640)

Ivan Vasilova4b6c63928d8
diff --git a/apps/studio/data/storage/bucket-object-download-mutation.ts b/apps/studio/data/storage/bucket-object-download-mutation.ts
deleted file mode 100644
index 7e9bcc3b4ac..00000000000
--- a/apps/studio/data/storage/bucket-object-download-mutation.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-import { useMutation } from '@tanstack/react-query'
-import { toast } from 'sonner'
-
-import { components } from 'data/api'
-import { fetchPost } from 'data/fetchers'
-import { API_URL, IS_PLATFORM } from 'lib/constants'
-import type { ResponseError, UseCustomMutationOptions } from 'types'
-
-type DownloadBucketObjectParams = {
- projectRef: string
- bucketId?: string
- path: string
- options?: components['schemas']['DownloadObjectBody']['options']
-}
-export const downloadBucketObject = async (
- { projectRef, bucketId, path, options }: DownloadBucketObjectParams,
- signal?: AbortSignal
-) => {
- if (!bucketId) throw new Error('bucketId is required')
-
- const response = await fetchPost(
- `${API_URL}${IS_PLATFORM ? '' : '/platform'}/storage/${projectRef}/buckets/${bucketId}/objects/download`,
- { path, options, abortSignal: signal }
- )
-
- if (response.error) throw response.error
- return response
-}
-
-type BucketObjectDeleteData = Awaited<ReturnType<typeof downloadBucketObject>>
-
-export const useBucketObjectDownloadMutation = ({
- onSuccess,
- onError,
- ...options
-}: Omit<
- UseCustomMutationOptions<BucketObjectDeleteData, ResponseError, DownloadBucketObjectParams>,
- 'mutationFn'
-> = {}) => {
- return useMutation<BucketObjectDeleteData, ResponseError, DownloadBucketObjectParams>({
- mutationFn: (vars) => downloadBucketObject(vars),
- async onSuccess(data, variables, context) {
- await onSuccess?.(data, variables, context)
- },
- async onError(data, variables, context) {
- if (onError === undefined) {
- toast.error(`Failed to download bucket object: ${data.message}`)
- } else {
- onError(data, variables, context)
- }
- },
- ...options,
- })
-}