getPipelineVersions: async ({ params }) => {
return await instance.get(`/pipelines/${params.pipelineName}/versions`);
},
- uploadPipeline: async ({ params, data }) => {
- return await instance.post(`/pipelines/${params.pipelineName}/upload`, { ...data });
+ uploadPipeline: async ({ params }) => {
+ return await instance.post(`/pipelines/${params.pipelineName}/upload`, params.data, {
+ headers: {
+ "Content-Type": "multipart/form-data",
+ },
+ });
},
};
// ==================================================================================
-import React from 'react';
+import React, { Component } from 'react';
import Form from 'react-bootstrap/Form';
import Button from 'react-bootstrap/Button';
import { notebook_url, UCMgr_baseUrl } from '../../../states';
import { pipelineAPI } from '../../../apis/pipeline';
-class UploadPipelineForm extends React.Component {
+class UploadPipelineForm extends Component {
constructor(props) {
super(props);
this.state = {
- fileName: '',
+ fileName: null,
plName: '',
UCMgr_baseUrl: UCMgr_baseUrl,
};
- this.handleInputChange = this.handleInputChange.bind(this);
+ this.handleFileChange = this.handleFileChange.bind(this);
}
popover = () => (
</Popover>
);
- handleInputChange(event) {
+ handleFileChange = (event) => {
console.log(event);
this.setState({
fileName: event.target.files[0],
+ }, () => {
+ console.log('handleFileChange', this.state.fileName);
});
- console.log('handleInputChange', this.fileName);
- }
+ };
handlePlNameChange = event => {
this.setState({
resetFrom = event => {
this.setState({
- fileName: '',
+ fileName: null,
plName: '',
});
console.log(this.state);
data.append('file', this.state.fileName);
pipelineAPI
- .uploadPipeline({ params: { pipelineName: this.state.plName }, data })
+ .uploadPipeline({ params: { pipelineName: this.state.plName, data: data } })
.then(res => {
console.log('Pipeline responsed ', res);
console.log('Status responsed ', res.status);
.then(function () {
// always executed
});
-
- console.log('something');
event.preventDefault();
};
/>
</Form.Group>
- <input type='file' className='form-control' name='upload_file' onChange={this.handleInputChange} />
+ <input type='file' className='form-control' name='upload_file' onChange={this.handleFileChange} />
<Button style={{ backgroundColor: '#6282f6' }} type='submit'> Upload </Button>
</Form>