Skip to content

Commit

Permalink
Merge pull request #7 from dabapps/file-names
Browse files Browse the repository at this point in the history
File names
  • Loading branch information
JakeSidSmith authored May 7, 2019
2 parents 536d2ca + c445e36 commit ea2d5b5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {},
Expand Down
3 changes: 3 additions & 0 deletions src/upload-file-to-s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ export const getUploadForm = (file: File): Promise<UploadData> => {
headers: {
'X-CSRFToken': Cookies.get('csrftoken'),
},
data: {
filename: file.name,
},
})
.then((uploadResponse: AxiosResponse<UploadData>) => {
return uploadFileToSignedUrl(uploadResponse.data, file);
Expand Down
13 changes: 13 additions & 0 deletions tests/update-file-to-s3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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];

Expand Down

0 comments on commit ea2d5b5

Please sign in to comment.