mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-22 17:31:03 +01:00
added upload functionality
This commit is contained in:
@@ -837,8 +837,7 @@ class SpiderManageApi(Resource):
|
||||
}
|
||||
|
||||
def upload(self):
|
||||
args = self.parser.parse_args()
|
||||
f = request.files[0]
|
||||
f = request.files['file']
|
||||
|
||||
if get_file_suffix(f.filename) != 'zip':
|
||||
return {
|
||||
@@ -856,3 +855,15 @@ class SpiderManageApi(Resource):
|
||||
if os.path.exists(dir_path):
|
||||
shutil.rmtree(dir_path)
|
||||
unzip_file(file_path, dir_path)
|
||||
|
||||
# copy to source folder
|
||||
output_path = os.path.join(PROJECT_SOURCE_FILE_FOLDER, f.filename.replace('.zip', ''))
|
||||
print(output_path)
|
||||
if os.path.exists(output_path):
|
||||
shutil.rmtree(output_path)
|
||||
shutil.copytree(dir_path, output_path)
|
||||
|
||||
return {
|
||||
'status': 'ok',
|
||||
'message': 'success'
|
||||
}
|
||||
|
||||
@@ -87,7 +87,7 @@
|
||||
:action="$request.baseUrl + '/spiders/manage/upload'"
|
||||
:on-success="onUploadSuccess"
|
||||
:file-list="fileList">
|
||||
<el-button size="small" type="primary">{{$t('Upload')}}</el-button>
|
||||
<el-button type="primary" icon="el-icon-upload">{{$t('Upload')}}</el-button>
|
||||
</el-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
@@ -493,6 +493,14 @@ export default {
|
||||
})
|
||||
},
|
||||
onUploadSuccess () {
|
||||
// clear fileList
|
||||
this.fileList = []
|
||||
|
||||
// fetch spider list
|
||||
this.$store.dispatch('spider/getSpiderList')
|
||||
|
||||
// close popup
|
||||
this.addCustomizedDialogVisible = false
|
||||
}
|
||||
},
|
||||
created () {
|
||||
|
||||
Reference in New Issue
Block a user