feat: 添加 S3 上传功能,包含预签名 URL 获取和上传选项
This commit is contained in:
3
auto-imports.d.ts
vendored
3
auto-imports.d.ts
vendored
@@ -138,6 +138,7 @@ declare global {
|
|||||||
const unref: typeof import('vue').unref
|
const unref: typeof import('vue').unref
|
||||||
const unrefElement: typeof import('@vueuse/core').unrefElement
|
const unrefElement: typeof import('@vueuse/core').unrefElement
|
||||||
const until: typeof import('@vueuse/core').until
|
const until: typeof import('@vueuse/core').until
|
||||||
|
const uploadToS3: typeof import('./src/utils/aws/s3').uploadToS3
|
||||||
const useActiveElement: typeof import('@vueuse/core').useActiveElement
|
const useActiveElement: typeof import('@vueuse/core').useActiveElement
|
||||||
const useAnimate: typeof import('@vueuse/core').useAnimate
|
const useAnimate: typeof import('@vueuse/core').useAnimate
|
||||||
const useAppUpdate: typeof import('./src/composables/useAppUpdate').useAppUpdate
|
const useAppUpdate: typeof import('./src/composables/useAppUpdate').useAppUpdate
|
||||||
@@ -308,6 +309,7 @@ declare global {
|
|||||||
const useToggle: typeof import('@vueuse/core').useToggle
|
const useToggle: typeof import('@vueuse/core').useToggle
|
||||||
const useTradingView: typeof import('./src/composables/useTradingView').useTradingView
|
const useTradingView: typeof import('./src/composables/useTradingView').useTradingView
|
||||||
const useTransition: typeof import('@vueuse/core').useTransition
|
const useTransition: typeof import('@vueuse/core').useTransition
|
||||||
|
const useUploadToS3: typeof import('./src/composables/useUploadToS3').useUploadToS3
|
||||||
const useUrlSearchParams: typeof import('@vueuse/core').useUrlSearchParams
|
const useUrlSearchParams: typeof import('@vueuse/core').useUrlSearchParams
|
||||||
const useUserMedia: typeof import('@vueuse/core').useUserMedia
|
const useUserMedia: typeof import('@vueuse/core').useUserMedia
|
||||||
const useUserStore: typeof import('./src/store/user').useUserStore
|
const useUserStore: typeof import('./src/store/user').useUserStore
|
||||||
@@ -503,6 +505,7 @@ declare module 'vue' {
|
|||||||
readonly unref: UnwrapRef<typeof import('vue')['unref']>
|
readonly unref: UnwrapRef<typeof import('vue')['unref']>
|
||||||
readonly unrefElement: UnwrapRef<typeof import('@vueuse/core')['unrefElement']>
|
readonly unrefElement: UnwrapRef<typeof import('@vueuse/core')['unrefElement']>
|
||||||
readonly until: UnwrapRef<typeof import('@vueuse/core')['until']>
|
readonly until: UnwrapRef<typeof import('@vueuse/core')['until']>
|
||||||
|
readonly uploadToS3: UnwrapRef<typeof import('./src/utils/aws/s3')['uploadToS3']>
|
||||||
readonly useActiveElement: UnwrapRef<typeof import('@vueuse/core')['useActiveElement']>
|
readonly useActiveElement: UnwrapRef<typeof import('@vueuse/core')['useActiveElement']>
|
||||||
readonly useAnimate: UnwrapRef<typeof import('@vueuse/core')['useAnimate']>
|
readonly useAnimate: UnwrapRef<typeof import('@vueuse/core')['useAnimate']>
|
||||||
readonly useAppUpdate: UnwrapRef<typeof import('./src/composables/useAppUpdate')['useAppUpdate']>
|
readonly useAppUpdate: UnwrapRef<typeof import('./src/composables/useAppUpdate')['useAppUpdate']>
|
||||||
|
|||||||
19
src/utils/aws/s3.ts
Normal file
19
src/utils/aws/s3.ts
Normal file
@@ -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
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
export * from "./aws/s3";
|
||||||
export * from "./ionic-helper";
|
export * from "./ionic-helper";
|
||||||
export * from "./is";
|
export * from "./is";
|
||||||
export * from "./pattern";
|
export * from "./pattern";
|
||||||
|
|||||||
Reference in New Issue
Block a user