Custom upload actions send data to Front end
Custom upload actions send data to Front end
Clarence
Posts: 19Questions: 7Answers: 0
new Field('image').validator(Validate.notEmpty()).upload(
new Upload(async (fileInfo, id) => {
const file = await readFile(fileInfo.file);
await rename(fileInfo.file, `${__dirname}/../public/uploads/{id}.{fileInfo.extn}`);
Upload.Db.file = `data:${fileInfo.mimetype};base64,${file.toString('base64')}`; <----- May I use this to set Upload.Db
Upload.Db.web_path = '/uploads/'+ id + '.' + fileInfo.extn; <----- May I use this to set Upload.Db
Upload.Db.system_path = `${__dirname}` + '/../public/uploads/' + id + '.' + fileInfo.extn; <----- May I use this to set Upload.Db
return id;
})
.db('files', 'id', {
filename: Upload.Db.FileName,
filesize: Upload.Db.FileSize,
web_path: Upload.Db.web_path, <----- This I want to send to front end
system_path: Upload.Db.system_path, <----- This I want to send to front end
file: Upload.Db.file <----- This I want to send to front end
})
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
I want to use like this
If you have a look at the Ajax response from the server when loading the table, it should already have those three parameters. Can you give me a link to the page so I can take a look please?
Thanks,
Allan
Thank I use other ways to solve the problem
I think I can express my problem more clearly.
My problem is that I want to save the image as "base64 image".
Then the front end can read this photo directly.
But I use
It can't be use.
This is what I use, you may find it similar in your DB structure
the render calls the data from the JSON returned which contains the BLOB field
I am still looking, however, for a solution to my problem of using the Upload with BLOB fields.
Also, you may note that upload cannot be used with BLOB field on the same table