2020-04-29 23:45:50 +00:00
|
|
|
'use strict'
|
|
|
|
const FileUtils = use('App/Utils/FileUtils');
|
|
|
|
class BookApiController {
|
|
|
|
async getPage({request, book, response}) {
|
|
|
|
const pageNumber = Number(request.params.pageNumber);
|
|
|
|
const file =
|
|
|
|
await FileUtils.getFile(`books/${book.book_folder}/${pageNumber}.jpg`);
|
|
|
|
if (file)
|
|
|
|
response.send(file);
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
code: 404, message: 'no file'
|
|
|
|
}
|
|
|
|
}
|
2020-04-30 02:34:14 +00:00
|
|
|
async getThumbnail({request, book, response}) {
|
|
|
|
const file = await FileUtils.getFile(`books/${book.book_folder}/1.jpg`);
|
|
|
|
if (file)
|
|
|
|
response.send(file);
|
|
|
|
else
|
|
|
|
return {
|
|
|
|
code: 404, message: 'no file'
|
|
|
|
}
|
|
|
|
}
|
2020-04-29 23:45:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = BookApiController
|