diff --git a/auto-imports.d.ts b/auto-imports.d.ts index 7327015..776f1c9 100644 --- a/auto-imports.d.ts +++ b/auto-imports.d.ts @@ -138,6 +138,7 @@ declare global { const unref: typeof import('vue').unref const unrefElement: typeof import('@vueuse/core').unrefElement const until: typeof import('@vueuse/core').until + const uploadToS3: typeof import('./src/utils/aws/s3').uploadToS3 const useActiveElement: typeof import('@vueuse/core').useActiveElement const useAnimate: typeof import('@vueuse/core').useAnimate const useAppUpdate: typeof import('./src/composables/useAppUpdate').useAppUpdate @@ -308,6 +309,7 @@ declare global { const useToggle: typeof import('@vueuse/core').useToggle const useTradingView: typeof import('./src/composables/useTradingView').useTradingView const useTransition: typeof import('@vueuse/core').useTransition + const useUploadToS3: typeof import('./src/composables/useUploadToS3').useUploadToS3 const useUrlSearchParams: typeof import('@vueuse/core').useUrlSearchParams const useUserMedia: typeof import('@vueuse/core').useUserMedia const useUserStore: typeof import('./src/store/user').useUserStore @@ -503,6 +505,7 @@ declare module 'vue' { readonly unref: UnwrapRef readonly unrefElement: UnwrapRef readonly until: UnwrapRef + readonly uploadToS3: UnwrapRef readonly useActiveElement: UnwrapRef readonly useAnimate: UnwrapRef readonly useAppUpdate: UnwrapRef diff --git a/src/utils/aws/s3.ts b/src/utils/aws/s3.ts new file mode 100644 index 0000000..29822ae --- /dev/null +++ b/src/utils/aws/s3.ts @@ -0,0 +1,19 @@ +import { client, safeClient } from "@/api"; + +interface PresignedUrlResponse { + uploadUrl: string; + fileUrl: string; + key: string; + expiresIn: number; +} + +interface UploadOptions { + onProgress?: (progress: number) => void; + signal?: AbortSignal; +} + +export function uploadToS3(file: File, options: UploadOptions = {}) { + const { onProgress, signal } = options || {}; + + // 1. 获取预签名 URL +} diff --git a/src/utils/index.ts b/src/utils/index.ts index 7ad319f..de24259 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1,3 +1,4 @@ +export * from "./aws/s3"; export * from "./ionic-helper"; export * from "./is"; export * from "./pattern";