Upload Workspace logo during onboarding (#542)
* Upload image * Upload image * Fix tests * Remove pictures from seeds * Fix storybook * Fix storybook * Fix storybook
This commit is contained in:
@ -4,7 +4,6 @@ import { KebabCase } from 'type-fest';
|
||||
import { BadRequestException } from '@nestjs/common';
|
||||
import { basename } from 'path';
|
||||
import { settings } from 'src/constants/settings';
|
||||
import { camelCase } from 'src/utils/camel-case';
|
||||
|
||||
type AllowedFolders = KebabCase<keyof typeof FileFolder>;
|
||||
|
||||
@ -20,10 +19,7 @@ export function checkFilePath(filePath: string): string {
|
||||
throw new BadRequestException(`Folder ${folder} is not allowed`);
|
||||
}
|
||||
|
||||
if (
|
||||
size &&
|
||||
!settings.storage.imageCropSizes[camelCase(folder)]?.includes(size)
|
||||
) {
|
||||
if (size && !settings.storage.imageCropSizes[folder]?.includes(size)) {
|
||||
throw new BadRequestException(`Size ${size} is not allowed`);
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
import { registerEnumType } from '@nestjs/graphql';
|
||||
|
||||
export enum FileFolder {
|
||||
ProfilePicture = 'profilePicture',
|
||||
ProfilePicture = 'profile-picture',
|
||||
WorkspaceLogo = 'workspace-logo',
|
||||
}
|
||||
|
||||
registerEnumType(FileFolder, {
|
||||
|
||||
@ -91,7 +91,7 @@ export class FileUploadService {
|
||||
images.map(async (image, index) => {
|
||||
const buffer = await image.toBuffer();
|
||||
|
||||
paths.push(`profile-picture/${cropSizes[index]}/${name}`);
|
||||
paths.push(`${fileFolder}/${cropSizes[index]}/${name}`);
|
||||
|
||||
return this.uploadFile({
|
||||
file: buffer,
|
||||
|
||||
Reference in New Issue
Block a user