1
1
import type { R2Bucket } from '@cloudflare/workers-types/experimental'
2
+ import { ofetch } from 'ofetch'
2
3
import mime from 'mime'
3
4
// import { imageMeta } from 'image-meta'
4
5
import type { H3Event } from 'h3'
@@ -35,7 +36,7 @@ export function useBlob () {
35
36
return {
36
37
async list ( options : BlobListOptions = { limit : 1000 } ) {
37
38
if ( proxyURL ) {
38
- return $fetch < BlobObject [ ] > ( '/api/_hub/blob' , {
39
+ return ofetch < BlobObject [ ] > ( '/api/_hub/blob' , {
39
40
baseURL : proxyURL ,
40
41
method : 'GET' ,
41
42
query : options
@@ -68,7 +69,7 @@ export function useBlob () {
68
69
async serve ( event : H3Event , pathname : string ) {
69
70
pathname = decodeURI ( pathname )
70
71
if ( proxyURL ) {
71
- return $fetch < ReadableStreamDefaultReader < any > > ( `/api/_hub/blob/${ pathname } ` , {
72
+ return ofetch < ReadableStreamDefaultReader < any > > ( `/api/_hub/blob/${ pathname } ` , {
72
73
baseURL : proxyURL ,
73
74
method : 'GET'
74
75
} )
@@ -92,7 +93,7 @@ export function useBlob () {
92
93
const headers : Record < string , string > = { }
93
94
if ( contentType ) { headers [ 'content-type' ] = contentType }
94
95
if ( contentLength ) { headers [ 'content-length' ] = contentLength }
95
- return await $fetch < BlobObject > ( joinURL ( '/api/_hub/blob' , pathname ) , {
96
+ return await ofetch < BlobObject > ( joinURL ( '/api/_hub/blob' , pathname ) , {
96
97
baseURL : proxyURL ,
97
98
method : 'PUT' ,
98
99
headers,
@@ -121,7 +122,7 @@ export function useBlob () {
121
122
async head ( pathname : string ) {
122
123
pathname = decodeURI ( pathname )
123
124
if ( proxyURL ) {
124
- const { headers } = await $fetch . raw < void > ( joinURL ( '/api/_hub/blob' , pathname ) , {
125
+ const { headers } = await ofetch . raw < void > ( joinURL ( '/api/_hub/blob' , pathname ) , {
125
126
baseURL : proxyURL ,
126
127
method : 'HEAD'
127
128
} )
@@ -139,7 +140,7 @@ export function useBlob () {
139
140
async delete ( pathname : string ) {
140
141
pathname = decodeURI ( pathname )
141
142
if ( proxyURL ) {
142
- await $fetch < void > ( `/api/_hub/blob/${ pathname } ` , {
143
+ await ofetch < void > ( `/api/_hub/blob/${ pathname } ` , {
143
144
baseURL : proxyURL ,
144
145
method : 'DELETE' ,
145
146
} )
0 commit comments