PicList/src/main/utils/uploader.js

38 lines
1009 B
JavaScript
Raw Normal View History

2017-11-29 10:13:35 -05:00
import weiboUpload from './weiboUpload'
import qiniuUpload from './qiniuUpload'
2017-12-20 22:18:54 -05:00
import tcYunUpload from './tcYunUpload'
2017-12-22 09:30:16 -05:00
import upYunUpload from './upYunUpload'
2018-04-06 10:01:30 -04:00
import githubUpload from './githubUpload'
2017-11-29 10:13:35 -05:00
import db from '../../datastore/index'
2017-12-22 09:30:16 -05:00
const checkUploader = (type) => {
const currentUploader = db.read().get(`picBed.${type}`).value()
if (currentUploader) {
return true
} else {
return false
}
}
2017-11-29 10:13:35 -05:00
const uploader = (img, type, webContents) => {
const uploadType = db.read().get('picBed.current').value()
2017-12-22 09:30:16 -05:00
if (checkUploader(uploadType)) {
switch (uploadType) {
case 'weibo':
return weiboUpload(img, type, webContents)
case 'qiniu':
return qiniuUpload(img, type, webContents)
case 'tcyun':
return tcYunUpload(img, type, webContents)
case 'upyun':
return upYunUpload(img, type, webContents)
2018-04-06 10:01:30 -04:00
case 'github':
return githubUpload(img, type, webContents)
2017-12-22 09:30:16 -05:00
}
} else {
return false
2017-11-29 10:13:35 -05:00
}
}
export default uploader