Skip to content

Commit

Permalink
moved logic of creating empty file
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathis Marcotte committed Apr 28, 2023
1 parent 6d707bc commit 54247c1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
7 changes: 6 additions & 1 deletion explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,12 @@ function AddFolderController($scope, SharedService) {
DEBUG.log('Calculated folder:', folder);

const s3 = new AWS.S3(AWS.config);
const params = { Bucket: $scope.add_folder.bucket, Key: folder };
// we need to attach a '.empty' file as the request is attempting to create a directory,
// so that the new folder is able to be displayed.
const emptyFile = new File([''], '.empty', { type: 'text/plain' });
const params = {
Body: emptyFile, Bucket, Key: folder + ".empty", ContentType: emptyFile.type,
};

DEBUG.log('Invoke headObject:', params);

Expand Down
15 changes: 0 additions & 15 deletions sw_modify_header.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@ self.addEventListener('fetch', (e) => {
});
e.respondWith(fetch(req));
}
// If there is a PUT request where the url ends with '/', then we need to attach
// a '.empty' file as the request is attempting to create a directory.
else if (e.request.url.endsWith('/')) {
const emptyFile = new File([''], '.empty', { type: 'text/plain' });
const modifiedUrl = e.request.url + ".empty"
const req = new Request(modifiedUrl, {
headers,
body: emptyFile,
method: e.request.method,
mode: e.request.mode,
credentials: e.request.credentials,
redirect: e.request.redirect
});
e.respondWith(fetch(req));
}
else {
// At this point, the user is trying to upload a file as either a single-part upload or
// a multi-part upload.
Expand Down

0 comments on commit 54247c1

Please sign in to comment.