1
0

fix: correct uri encode paths in fs module (#2922)

Signed-off-by: Evan Song <theevansong@gmail.com>
This commit is contained in:
Evan Song
2024-11-05 16:35:43 -07:00
committed by GitHub
parent 907b1f67ed
commit ff72c906ba

View File

@@ -703,7 +703,8 @@ const retryWithAuth = async (requestFn: () => Promise<any>) => {
const listDirContents = (path: string, page: number, pageSize: number) => {
return retryWithAuth(async () => {
return await PyroFetch(`/list?path=${path}&page=${page}&page_size=${pageSize}`, {
const encodedPath = encodeURIComponent(path);
return await PyroFetch(`/list?path=${encodedPath}&page=${page}&page_size=${pageSize}`, {
override: internalServerRefrence.value.fs.auth,
retry: false,
});
@@ -712,7 +713,8 @@ const listDirContents = (path: string, page: number, pageSize: number) => {
const createFileOrFolder = (path: string, type: "file" | "directory") => {
return retryWithAuth(async () => {
return await PyroFetch(`/create?path=${path}&type=${type}`, {
const encodedPath = encodeURIComponent(path);
return await PyroFetch(`/create?path=${encodedPath}&type=${type}`, {
method: "POST",
contentType: "application/octet-stream",
override: internalServerRefrence.value.fs.auth,
@@ -722,7 +724,8 @@ const createFileOrFolder = (path: string, type: "file" | "directory") => {
const uploadFile = (path: string, file: File) => {
return retryWithAuth(async () => {
return await PyroFetch(`/create?path=${path}&type=file`, {
const encodedPath = encodeURIComponent(path);
return await PyroFetch(`/create?path=${encodedPath}&type=file`, {
method: "POST",
contentType: "application/octet-stream",
body: file,
@@ -803,7 +806,8 @@ const deleteFileOrFolder = (path: string, recursive: boolean) => {
const downloadFile = (path: string, raw?: boolean) => {
return retryWithAuth(async () => {
const fileData = await PyroFetch(`/download?path=${path}`, {
const encodedPath = encodeURIComponent(path);
const fileData = await PyroFetch(`/download?path=${encodedPath}`, {
override: internalServerRefrence.value.fs.auth,
});