Skip to content

Commit ea2d5b5

Browse files
authored
Merge pull request #7 from dabapps/file-names
File names
2 parents 536d2ca + c445e36 commit ea2d5b5

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dabapps/django-s3-file-upload",
3-
"version": "0.0.2",
3+
"version": "0.0.3",
44
"description": "Upload files from the browser to S3 - client side implementation",
55
"main": "dist/index.js",
66
"directories": {},

src/upload-file-to-s3.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ export const getUploadForm = (file: File): Promise<UploadData> => {
5959
headers: {
6060
'X-CSRFToken': Cookies.get('csrftoken'),
6161
},
62+
data: {
63+
filename: file.name,
64+
},
6265
})
6366
.then((uploadResponse: AxiosResponse<UploadData>) => {
6467
return uploadFileToSignedUrl(uploadResponse.data, file);

tests/update-file-to-s3.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,19 @@ describe('Django S3 File Upload', () => {
3131
// Check that it was called
3232
expect(requestCalls.length).toBe(1);
3333

34+
expect(requestCalls[0].arguments).toEqual([
35+
{
36+
method: 'POST',
37+
url: '/api/s3-file-uploads/',
38+
headers: {
39+
'X-CSRFToken': undefined,
40+
},
41+
data: {
42+
filename: 'llama',
43+
},
44+
},
45+
]);
46+
3447
// Get the .then calls
3548
const { thenCalls } = requestCalls[0];
3649

0 commit comments

Comments
 (0)