@edgestore/server
Version:
Upload files with ease from React/Next.js
240 lines • 6.31 kB
TypeScript
import { type AnyContext, type AnyMetadata, type AnyRouter } from '@edgestore/shared';
type FileInfoForUpload = {
size: number;
extension: string;
type?: string;
isPublic: boolean;
path: {
key: string;
value: string;
}[];
metadata: AnyMetadata;
fileName?: string;
replaceTargetUrl?: string;
temporary: boolean;
};
export type SimpleOperator = 'eq' | 'neq' | 'gt' | 'gte' | 'lt' | 'lte' | 'startsWith' | 'endsWith';
export type Comparison<TType = string> = TType | Partial<{
[K in SimpleOperator]: TType;
} & {
between: [TType, TType];
}>;
type ListFilesFilter = {
AND?: ListFilesFilter[];
OR?: ListFilesFilter[];
uploadedAt?: Comparison<Date>;
path?: Partial<{
[key: string]: Comparison;
}>;
metadata?: Partial<{
[key: string]: Comparison;
}>;
};
type Pagination = {
currentPage: number;
pageSize: number;
};
export declare const edgeStoreRawSdk: {
getToken(params: {
accessKey: string;
secretKey: string;
ctx: AnyContext;
router: AnyRouter;
}): Promise<string>;
getFile({ accessKey, secretKey, url, }: {
accessKey: string;
secretKey: string;
url: string;
}): Promise<{
url: string;
size: number;
uploadedAt: string;
path: Record<string, string>;
metadata: Record<string, string>;
}>;
requestUpload({ accessKey, secretKey, bucketName, bucketType, fileInfo, multipart, }: {
accessKey: string;
secretKey: string;
bucketName: string;
bucketType: string;
fileInfo: FileInfoForUpload;
multipart?: {
parts: number[];
};
}): Promise<{
multipart: {
key: string;
uploadId: string;
parts: {
partNumber: number;
signedUrl: string;
}[];
} | undefined;
signedUrl: string | undefined;
accessUrl: string;
path: string;
thumbnailUrl: string | null;
}>;
requestUploadParts({ accessKey, secretKey, key, multipart, }: {
accessKey: string;
secretKey: string;
key: string;
multipart: {
uploadId?: string;
parts: number[];
};
}): Promise<{
multipart: {
uploadId: string;
parts: {
partNumber: number;
signedUrl: string;
}[];
};
}>;
completeMultipartUpload({ accessKey, secretKey, uploadId, key, parts, }: {
accessKey: string;
secretKey: string;
uploadId: string;
key: string;
parts: {
partNumber: number;
eTag: string;
}[];
}): Promise<{
success: boolean;
}>;
confirmUpload({ accessKey, secretKey, url, }: {
accessKey: string;
secretKey: string;
url: string;
}): Promise<{
success: boolean;
}>;
deleteFile({ accessKey, secretKey, url, }: {
accessKey: string;
secretKey: string;
url: string;
}): Promise<{
success: boolean;
}>;
listFiles({ accessKey, secretKey, bucketName, filter, pagination, }: {
accessKey: string;
secretKey: string;
bucketName: string;
filter?: ListFilesFilter;
pagination?: Pagination;
}): Promise<{
data: {
url: string;
thumbnailUrl: string | null;
size: number;
uploadedAt: string;
path: Record<string, string>;
metadata: Record<string, string>;
}[];
pagination: {
currentPage: number;
pageSize: number;
totalPages: number;
totalCount: number;
};
}>;
};
export declare function initEdgeStoreSdk(params: {
accessKey?: string;
secretKey?: string;
}): {
getToken(params: {
ctx: AnyContext;
router: AnyRouter;
}): Promise<string>;
getFile({ url }: {
url: string;
}): Promise<{
url: string;
size: number;
uploadedAt: string;
path: Record<string, string>;
metadata: Record<string, string>;
}>;
requestUpload({ bucketName, bucketType, fileInfo, multipart, }: {
bucketName: string;
bucketType: string;
fileInfo: FileInfoForUpload;
multipart?: {
parts: number[];
};
}): Promise<{
multipart: {
key: string;
uploadId: string;
parts: {
partNumber: number;
signedUrl: string;
}[];
} | undefined;
signedUrl: string | undefined;
accessUrl: string;
path: string;
thumbnailUrl: string | null;
}>;
requestUploadParts({ key, multipart, }: {
key: string;
multipart: {
uploadId?: string;
parts: number[];
};
}): Promise<{
multipart: {
uploadId: string;
parts: {
partNumber: number;
signedUrl: string;
}[];
};
}>;
completeMultipartUpload({ uploadId, key, parts, }: {
uploadId: string;
key: string;
parts: {
partNumber: number;
eTag: string;
}[];
}): Promise<{
success: boolean;
}>;
confirmUpload({ url }: {
url: string;
}): Promise<{
success: boolean;
}>;
deleteFile({ url }: {
url: string;
}): Promise<{
success: boolean;
}>;
listFiles(params: {
bucketName: string;
filter?: ListFilesFilter;
pagination?: Pagination;
}): Promise<{
data: {
url: string;
thumbnailUrl: string | null;
size: number;
uploadedAt: string;
path: Record<string, string>;
metadata: Record<string, string>;
}[];
pagination: {
currentPage: number;
pageSize: number;
totalPages: number;
totalCount: number;
};
}>;
};
export type EdgeStoreSdk = ReturnType<typeof initEdgeStoreSdk>;
export {};
//# sourceMappingURL=index.d.ts.map