Skip to content

Commit 6a38a09

Browse files
authored
Fix folder download (#3264)
1 parent 78990e3 commit 6a38a09

File tree

1 file changed

+9
-2
lines changed
  • web-app/src/screens/Console/Buckets/ListBuckets/Objects

1 file changed

+9
-2
lines changed

web-app/src/screens/Console/Buckets/ListBuckets/Objects/utils.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1616

1717
import { BucketObjectItem } from "./ListObjects/types";
18-
import { encodeURLString } from "../../../../../common/utils";
18+
import { decodeURLString, encodeURLString } from "../../../../../common/utils";
1919
import { removeTrace } from "../../../ObjectBrowser/transferManager";
2020
import store from "../../../../../store";
2121
import { ContentType, PermissionResource } from "api/consoleApi";
@@ -64,6 +64,11 @@ export const downloadSelectedAsZip = async (
6464
);
6565
}
6666
};
67+
68+
const isFolder = (objectPath: string) => {
69+
return decodeURLString(objectPath).endsWith("/");
70+
};
71+
6772
export const download = (
6873
bucketName: string,
6974
objectPath: string,
@@ -116,7 +121,9 @@ export const download = (
116121
req.responseType = "blob";
117122
req.onreadystatechange = () => {
118123
if (req.readyState === XMLHttpRequest.DONE) {
119-
let completeDownload = req.response.size === fileSize;
124+
// Ensure object was downloaded fully, if it's a folder we don't get the fileSize
125+
let completeDownload =
126+
isFolder(objectPath) || req.response.size === fileSize;
120127

121128
if (req.status === StatusCodes.OK && completeDownload) {
122129
const rspHeader = req.getResponseHeader("Content-Disposition");

0 commit comments

Comments
 (0)