Browse Source

using micropub-express as a guess/guide

master
Rich Brown 1 year ago
parent
commit
ae74435b93
1 changed files with 6 additions and 4 deletions
  1. +6
    -4
      routes/createRouter.js

+ 6
- 4
routes/createRouter.js View File

@@ -28,9 +28,11 @@ function sanitizeFile(file, cb) {

createRouter.post('/form', upload.single('file'), (req, res) => {
const { file, body: { title, body, arrayOfTags } } = req;
console.log(Buffer.from(file.buffer));
// const img = fs.readFileSync(file.path);
// const encode_image = file.toS
const image = {
filename: file.originalname,
buffer: file.buffer,
};
console.log(image);
return req.app.locals.mp
.create(
{
@@ -38,7 +40,7 @@ createRouter.post('/form', upload.single('file'), (req, res) => {
name: title, // i thought MF syntax was 'p-name' but voxpelli's formattr turns NAME to TITLE
content: body,
category: arrayOfTags,
photo: Buffer.from(file.buffer),
photo: [image],
},
'multipart',
)


Loading…
Cancel
Save