Skip to content

Commit b69ed3e

Browse files
committed
fix: upload URL size arg AdminForth/2032/fix-upload-plugin-and-storage-
StorageAdapter.getUploadSignedUrl gets an optional contentLength. When it is passed, the adapter binds the upload URL to that exact size, so a client can't declare a small file and upload a bigger one. Adapters that ignore the argument keep working.
1 parent a1fa458 commit b69ed3e

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎adminforth/types/adapters/StorageAdapter.ts‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ export interface StorageAdapter {
1515
* @param key - The key of the file to be uploaded e.g. "uploads/file.txt"
1616
* @param expiresIn - The expiration time in seconds for the presigned URL
1717
* @param contentType - The content type of the file to be uploaded, e.g. "image/png"
18+
* @param contentLength - Optional exact size of the file in bytes. When passed, the upload should be rejected if the body has another size.
1819
*
1920
* @returns A promise that resolves to an object containing the upload URL and any extra parameters which should be sent with PUT multipart form data
2021
*/
21-
getUploadSignedUrl(key: string, contentType: string, expiresIn?: number): Promise<{
22+
getUploadSignedUrl(key: string, contentType: string, expiresIn?: number, contentLength?: number): Promise<{
2223
uploadUrl: string;
2324
uploadExtraParams?: Record<string, string>;
2425
}>;

0 commit comments

Comments
 (0)