diff --git a/package-lock.json b/package-lock.json index 93c549e..c0c13be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "@dabapps/django-s3-file-upload", - "version": "0.0.2", + "version": "0.0.3", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index d2cbf24..68acd2e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@dabapps/django-s3-file-upload", - "version": "0.0.2", + "version": "0.0.3", "description": "Upload files from the browser to S3 - client side implementation", "main": "dist/index.js", "directories": {}, diff --git a/src/upload-file-to-s3.ts b/src/upload-file-to-s3.ts index 45fea79..6805aec 100644 --- a/src/upload-file-to-s3.ts +++ b/src/upload-file-to-s3.ts @@ -59,6 +59,9 @@ export const getUploadForm = (file: File): Promise => { headers: { 'X-CSRFToken': Cookies.get('csrftoken'), }, + data: { + filename: file.name, + }, }) .then((uploadResponse: AxiosResponse) => { return uploadFileToSignedUrl(uploadResponse.data, file); diff --git a/tests/update-file-to-s3.ts b/tests/update-file-to-s3.ts index 4a2be96..b3a8ec5 100644 --- a/tests/update-file-to-s3.ts +++ b/tests/update-file-to-s3.ts @@ -31,6 +31,19 @@ describe('Django S3 File Upload', () => { // Check that it was called expect(requestCalls.length).toBe(1); + expect(requestCalls[0].arguments).toEqual([ + { + method: 'POST', + url: '/api/s3-file-uploads/', + headers: { + 'X-CSRFToken': undefined, + }, + data: { + filename: 'llama', + }, + }, + ]); + // Get the .then calls const { thenCalls } = requestCalls[0];