|
|
@@ -61,20 +61,7 @@ class ExampleController extends BaseController {
|
|
|
const self = this;
|
|
|
const { ctx, service } = this;
|
|
|
let tmpDir = service.storage.getStorageDir();
|
|
|
- // for (const file of ctx.request.files) {
|
|
|
- // this.app.logger.info('file:', file);
|
|
|
-
|
|
|
- // try {
|
|
|
- // let tmpFile = fs.readFileSync(file.filepath)
|
|
|
- // fs.writeFileSync(path.join(tmpDir, file.filename), tmpFile)
|
|
|
- // } finally {
|
|
|
- // await fs.unlink(file.filepath, function(){});
|
|
|
- // }
|
|
|
- // const fileStream = fs.createReadStream(path.join(tmpDir, file.filename))
|
|
|
- // const uploadRes = await service.example.uploadFileToSMMS(fileStream);
|
|
|
- // }
|
|
|
const file = ctx.request.files[0];
|
|
|
- //this.app.logger.info('file:', file);
|
|
|
|
|
|
try {
|
|
|
let tmpFile = fs.readFileSync(file.filepath)
|
|
|
@@ -88,6 +75,28 @@ class ExampleController extends BaseController {
|
|
|
self.sendData(uploadRes);
|
|
|
}
|
|
|
|
|
|
+ async uploadExtension() {
|
|
|
+ const self = this;
|
|
|
+ const { ctx, service } = this;
|
|
|
+ const data = {};
|
|
|
+ let tmpDir = service.storage.getStorageDir();
|
|
|
+
|
|
|
+ const file = ctx.request.files[0];
|
|
|
+ this.app.logger.info('file:', file);
|
|
|
+
|
|
|
+ try {
|
|
|
+ let tmpFile = fs.readFileSync(file.filepath)
|
|
|
+ fs.writeFileSync(path.join(tmpDir, file.filename), tmpFile)
|
|
|
+ } finally {
|
|
|
+ await fs.unlink(file.filepath, function(){});
|
|
|
+ }
|
|
|
+
|
|
|
+ const filePath = path.join(tmpDir, file.filename);
|
|
|
+ await service.example.loadExtension(filePath);
|
|
|
+
|
|
|
+ self.sendData(data);
|
|
|
+ }
|
|
|
+
|
|
|
async setShortcut() {
|
|
|
const self = this;
|
|
|
const { ctx, service } = this;
|