Fix bug when deleting objects with % in the name (#876)

* Fix bug when deleting object puts with % in the name

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>

* Remove unused import

Signed-off-by: Daniel Valdivia <18384552+dvaldivia@users.noreply.github.com>
This commit is contained in:
Daniel Valdivia
2021-07-20 18:42:50 -07:00
committed by GitHub
parent 9b6d14c752
commit c31af8bb8c
4 changed files with 9 additions and 6 deletions

View File

@@ -53,7 +53,9 @@ const DeleteObject = ({
if (selectedObject.endsWith("/")) {
recursive = true;
}
setDeleteLoading(true);
// Escape object name
selectedObject = encodeURIComponent(selectedObject);
api
.invoke(
"DELETE",

View File

@@ -468,7 +468,8 @@ const ListObjects = ({
let files = e.target.files;
let uploadUrl = `/api/v1/buckets/${bucketName}/objects/upload`;
if (path !== "") {
uploadUrl = `${uploadUrl}?prefix=${path}`;
const encodedPath = encodeURIComponent(path);
uploadUrl = `${uploadUrl}?prefix=${encodedPath}`;
}
let xhr = new XMLHttpRequest();
const areMultipleFiles = files.length > 1 ? true : false;

View File

@@ -219,10 +219,11 @@ const ObjectDetails = ({
useEffect(() => {
if (loadObjectData) {
const encodedPath = encodeURIComponent(pathInBucket);
api
.invoke(
"GET",
`/api/v1/buckets/${bucketName}/objects?prefix=${pathInBucket}&with_versions=true`
`/api/v1/buckets/${bucketName}/objects?prefix=${encodedPath}&with_versions=true`
)
.then((res: IFileInfo[]) => {
const result = get(res, "objects", []);

View File

@@ -25,9 +25,8 @@ export const download = (
) => {
const anchor = document.createElement("a");
document.body.appendChild(anchor);
const allPathData = objectPath.split("/");
let path = `/api/v1/buckets/${bucketName}/objects/download?prefix=${objectPath}`;
const encodedPath = encodeURIComponent(objectPath);
let path = `/api/v1/buckets/${bucketName}/objects/download?prefix=${encodedPath}`;
if (!isNullOrUndefined(versionID) && versionID !== "null") {
path = path.concat(`&version_id=${versionID}`);
}