diff --git a/packages/bruno-app/src/components/RawFilePickerEditor/index.js b/packages/bruno-app/src/components/RawFilePickerEditor/index.js
new file mode 100644
index 000000000..87fefa598
--- /dev/null
+++ b/packages/bruno-app/src/components/RawFilePickerEditor/index.js
@@ -0,0 +1,54 @@
+import React from 'react';
+import path from 'path';
+import { useDispatch } from 'react-redux';
+import { browseFile } from 'providers/ReduxStore/slices/collections/actions';
+import { IconX } from '@tabler/icons';
+import { isWindowsOS } from 'utils/common/platform';
+import slash from 'utils/common/slash';
+
+const RawFilePickerEditor = ({ value, onChange, collection }) => {
+ value = value || '';
+ const dispatch = useDispatch();
+ const separator = isWindowsOS() ? '\\' : '/';
+ const filename = value != '' ? value.split(separator).pop() : value;
+ const title = `- ${filename}`;
+
+ const browse = () => {
+ dispatch(browseFile())
+ .then((filePath) => {
+ const collectionDir = collection.pathname;
+
+ filePath = filePath.startsWith(collectionDir) ?
+ path.relative(slash(collectionDir), slash(filePath)) : filePath;
+
+ onChange(filePath);
+ })
+ .catch((error) => {
+ console.error(error);
+ });
+ };
+
+ const clear = () => {
+ onChange(null);
+ };
+
+ return filename.length > 0 ? (
+
+
+
+ {filename}
+
+ ) : (
+
+ );
+};
+
+export default RawFilePickerEditor;
\ No newline at end of file
diff --git a/packages/bruno-app/src/components/RequestPane/RawFileParams/index.js b/packages/bruno-app/src/components/RequestPane/RawFileParams/index.js
index 663c9a0dc..55ff34171 100644
--- a/packages/bruno-app/src/components/RequestPane/RawFileParams/index.js
+++ b/packages/bruno-app/src/components/RequestPane/RawFileParams/index.js
@@ -3,23 +3,20 @@ import get from 'lodash/get';
import cloneDeep from 'lodash/cloneDeep';
import { useDispatch } from 'react-redux';
import { useTheme } from 'providers/Theme';
-import { updateRawFile } from 'providers/ReduxStore/slices/collections';
import { sendRequest, saveRequest } from 'providers/ReduxStore/slices/collections/actions';
import StyledWrapper from './StyledWrapper';
-import FilePickerEditor from 'components/FilePickerEditor';
+import RawFilePickerEditor from 'components/RawFilePickerEditor';
+import { updateRequestBody } from 'providers/ReduxStore/slices/collections/index';
const RawFileParams = ({ item, collection }) => {
const dispatch = useDispatch();
const { storedTheme } = useTheme();
const fileName = item.draft ? get(item, 'draft.request.body.rawFile') : get(item, 'request.body.rawFile') || [];
- const handleFileChange = (e, __filename) => {
- const fileName = cloneDeep(__filename);
- fileName.value = e.target.value;
-
+ const handleFileChange = (e) => {
dispatch(
- updateRawFile({
- param: fileName,
+ updateRequestBody({
+ content: e.target.value,
itemUid: item.uid,
collectionUid: collection.uid
})
@@ -28,16 +25,15 @@ const RawFileParams = ({ item, collection }) => {
return (
-
handleFileChange(
{
target: {
value: newValue
}
- },
- fileName
+ }
)
}
collection={collection} />
diff --git a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
index 1079af8c0..58ac31df3 100644
--- a/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
+++ b/packages/bruno-app/src/providers/ReduxStore/slices/collections/index.js
@@ -762,23 +762,6 @@ export const collectionsSlice = createSlice({
}
}
},
- updateRawFile: (state, action) => {
- const collection = findCollectionByUid(state.collections, action.payload.collectionUid);
-
- if(collection) {
- const item = findItemInCollection(collection, action.payload.itemUid);
-
- if (item && isItemARequest(item)) {
- if (!item.draft) {
- item.draft = cloneDeep(item);
- }
- const param = find(item.draft.request.body.rawFile, (p) => p.uid === action.payload.param.uid);
- if (param) {
- param.value = action.payload.param.value;
- }
- }
- }
- },
updateRequestAuthMode: (state, action) => {
const collection = findCollectionByUid(state.collections, action.payload.collectionUid);
@@ -1682,7 +1665,6 @@ export const {
addMultipartFormParam,
updateMultipartFormParam,
deleteMultipartFormParam,
- updateRawFile,
updateRequestAuthMode,
updateRequestBodyMode,
updateRequestBody,
diff --git a/packages/bruno-schema/src/collections/index.js b/packages/bruno-schema/src/collections/index.js
index f52a5e774..35ec2979f 100644
--- a/packages/bruno-schema/src/collections/index.js
+++ b/packages/bruno-schema/src/collections/index.js
@@ -83,7 +83,8 @@ const requestBodySchema = Yup.object({
sparql: Yup.string().nullable(),
formUrlEncoded: Yup.array().of(keyValueSchema).nullable(),
multipartForm: Yup.array().of(multipartFormSchema).nullable(),
- graphql: graphqlBodySchema.nullable()
+ graphql: graphqlBodySchema.nullable(),
+ rawFile: Yup.string().nullable(),
})
.noUnknown(true)
.strict();