|
|
@ -577,6 +577,59 @@ module.exports = function (fastify, opts, next) {
|
|
|
|
// });
|
|
|
|
// });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// fastify.route({
|
|
|
|
|
|
|
|
// method: 'POST',
|
|
|
|
|
|
|
|
// url: '/api/users/profile-picture-supplier',
|
|
|
|
|
|
|
|
// schema: {
|
|
|
|
|
|
|
|
// tags: ['Supplier'],
|
|
|
|
|
|
|
|
// description: 'Upload a profile picture for a supplier',
|
|
|
|
|
|
|
|
// summary: 'Upload a profile picture for a supplier',
|
|
|
|
|
|
|
|
// params: {
|
|
|
|
|
|
|
|
// type: 'object',
|
|
|
|
|
|
|
|
// properties: {
|
|
|
|
|
|
|
|
// supplierId: {
|
|
|
|
|
|
|
|
// type: 'string',
|
|
|
|
|
|
|
|
// description: 'Supplier ID',
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// consumes: ['multipart/form-data'],
|
|
|
|
|
|
|
|
// body: {
|
|
|
|
|
|
|
|
// type: 'object',
|
|
|
|
|
|
|
|
// properties: {
|
|
|
|
|
|
|
|
// picture: {
|
|
|
|
|
|
|
|
// type: 'string',
|
|
|
|
|
|
|
|
// description: 'Profile picture file',
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// required: ['picture'],
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// response: {
|
|
|
|
|
|
|
|
// 200: {
|
|
|
|
|
|
|
|
// description: 'Profile picture uploaded successfully',
|
|
|
|
|
|
|
|
// type: 'object',
|
|
|
|
|
|
|
|
// properties: {
|
|
|
|
|
|
|
|
// message: { type: 'string' },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// 400: {
|
|
|
|
|
|
|
|
// description: 'Failed to upload profile picture',
|
|
|
|
|
|
|
|
// type: 'object',
|
|
|
|
|
|
|
|
// properties: {
|
|
|
|
|
|
|
|
// error: { type: 'string' },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// 500: {
|
|
|
|
|
|
|
|
// description: 'Internal server error',
|
|
|
|
|
|
|
|
// type: 'object',
|
|
|
|
|
|
|
|
// properties: {
|
|
|
|
|
|
|
|
// error: { type: 'string' },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// },
|
|
|
|
|
|
|
|
// handler: validationHandler.uploadProfilePicture,
|
|
|
|
|
|
|
|
// });
|
|
|
|
fastify.route({
|
|
|
|
fastify.route({
|
|
|
|
method: 'POST',
|
|
|
|
method: 'POST',
|
|
|
|
url: '/api/users/profile-picture-supplier/:supplierId',
|
|
|
|
url: '/api/users/profile-picture-supplier/:supplierId',
|
|
|
@ -598,8 +651,13 @@ module.exports = function (fastify, opts, next) {
|
|
|
|
type: 'object',
|
|
|
|
type: 'object',
|
|
|
|
properties: {
|
|
|
|
properties: {
|
|
|
|
picture: {
|
|
|
|
picture: {
|
|
|
|
type: 'string',
|
|
|
|
type: 'object',
|
|
|
|
description: 'Profile picture file',
|
|
|
|
properties: {
|
|
|
|
|
|
|
|
data: { type: 'string' }, // Remove the "format" property
|
|
|
|
|
|
|
|
encoding: { type: 'string' },
|
|
|
|
|
|
|
|
filename: { type: 'string' },
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
required: ['data', 'encoding', 'filename'], // Add required properties
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
required: ['picture'],
|
|
|
|
required: ['picture'],
|
|
|
@ -632,7 +690,6 @@ module.exports = function (fastify, opts, next) {
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const multer = require('multer');
|
|
|
|
const multer = require('multer');
|
|
|
|
const fs = require('fs');
|
|
|
|
const fs = require('fs');
|
|
|
|
|
|
|
|
|
|
|
|