Skip to content

Commit 7e93a2b

Browse files
committed
Send more data while uploading file
1 parent 3790ad9 commit 7e93a2b

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/components/form.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,9 @@ export class FormFileInput extends React.Component {
216216
this.setState({loading: true});
217217

218218
let formData = new FormData();
219+
formData.append('field_name', this.context.fieldName);
220+
formData.append('model_name', this.context.modelName);
221+
formData.append('coordinates', JSON.stringify(this.props.name.split('-').slice(1)));
219222
formData.append('file', e.target.files[0]);
220223

221224
fetch(endpoint, {

src/form.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,9 @@ export default class Form extends React.Component {
173173
<fieldset className="module aligned">
174174
<EditorContext.Provider
175175
value={{
176-
fileUploadEndpoint: this.props.fileUploadEndpoint
176+
fileUploadEndpoint: this.props.fileUploadEndpoint,
177+
fieldName: this.props.fieldName,
178+
modelName: this.props.modelName,
177179
}}
178180
>
179181
{this.getFields()}

src/renderer.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ export default function JSONForm(config) {
77
this.schema = config.schema;
88
this.data = config.data;
99
this.fileUploadEndpoint = config.fileUploadEndpoint;
10+
this.fieldName = config.fieldName;
11+
this.modelName = config.modelName;
1012

1113
this.render = function() {
1214
ReactDOM.render(
@@ -15,6 +17,8 @@ export default function JSONForm(config) {
1517
dataInputId={this.dataInputId}
1618
data={this.data}
1719
fileUploadEndpoint={this.fileUploadEndpoint}
20+
fieldName={this.fieldName}
21+
modelName={this.modelName}
1822
/>,
1923
document.getElementById(this.containerId)
2024
);

0 commit comments

Comments
 (0)