hi brian
all good for now but when i try to post text without image it gives error
this is my create.js file
excluding comments and console log s
//=========================================================
module.exports = async function(req, res) {
const postBody = req.body.postBody
const file = req.file('imagefile')
const options =
{ // This is the usual stuff
adapter: require('skipper-better-s3')
, key: '*************************'
, secret: '**************************************************'
, bucket: '***************'
// Let's use the custom s3params to upload this file as publicly
// readable by anyone
, s3params: { ACL: 'public-read' }
// And while we are at it, let's monitor the progress of this upload
, onProgress: progress => sails.log.verbose('Upload progress:', progress)
}
file.upload(options, async (err, files) => {
if (err) {
return res.serverError(err.toString())
}
const fileURL = files[0].extra.Location
const userId = req.session.userId
await Post.create({text: postBody, user: userId, fileUrl: fileURL}).fetch()
res.redirect('/post')
});
}