-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebug.js
55 lines (53 loc) · 2.66 KB
/
debug.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! artistController
/* const postArtistImage = async (req, res ,next) => {
if(!req.files) throw new Error('Missing image!')
const file = req.files.files
if(!file.mimetype.startsWith('image')) throw new Error('Please upload a image file type!')
if(file.size > process.env.MAX_FILE_SIZE) throw new Error(`Image exceeds size of ${process.env.MAX_FILE_SIZE}`)
file.name = `photo_${file.name}`
file.mv(path.resolve(__dirname,`${process.env.FILE_UPLOAD_PATH}`, file.name), async (err) => {
if(err) throw new Error('Problem uploading photo')
await Artist.findByIdAndUpdate(req.params.artistId, {image: file.name})
res
.status(200)
.setHeader('Content-Type', 'application/json')
.json({success: true, data: file.name})
})
} */
//og: req.files.file
//! Instructions
/* const postArtistImage = async (req, res, next) => {
if (req.files) throw new Error (`Missing Images!: ${err.message}`);
const file = req.files.file
if (!file.mimetype.startsWith('image')) throw new Error (`Please upload an image file type : ${err.message}`)
if (file.size > process.env.MAX_FILE_SIZE) throw new Error(`Image exceeds size of ${process.env.MAX_FILE_SIZE} ${err.message}`);
file.name = `photo_${path.parse(file.name).ext}`
const filePath = __dirname + '/files/' + file.name
file.mv(filePath, async (err) => {
if (err) throw new Error(`Problem uploading photo ${err.message}`);
await Artist.findByIdAndUpdate(req.params.artistId, {image: file.name})
res
.status(200)
.setHeader('Content-Type', 'application/json')
.json({ success: true, data: file.name});
})
} */
//! sent teams
/* const postArtistImage = async (req, res ,next) => {
if(!req.files) throw new Error('Missing image!')
const file = req.files.file
if(!file.mimetype.startsWith('image')) throw new Error('Please upload a image file type!')
if(file.size > process.env.MAX_FILE_SIZE) throw new Error(`Image exceeds size of ${process.env.MAX_FILE_SIZE}`)
file.name = `photo_${path.parse(file.name).ext}`
const filePath = process.env.FILE_UPLOAD_PATH + file.name
// file.mv(path.resolve(__dirname,`${process.env.FILE_UPLOAD_PATH}`, file.name), async (err) => {
file.mv(filePath, async (err) => {
if(err) throw new Error('Problem uploading photo')
await Artist.findByIdAndUpdate(req.params.artistId, {image: file.name})
res
.status(200)
.setHeader('Content-Type', 'application/json')
.json({success: true, data: file.name})
})
}
*/