Skip to content

Commit

Permalink
feat: upload file
Browse files Browse the repository at this point in the history
  • Loading branch information
truongnguyenptn committed Oct 13, 2023
1 parent dc4a198 commit 56e20cf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
1 change: 0 additions & 1 deletion src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { UserModule } from './user/user.module'
import { JwtModule } from '@nestjs/jwt'
import { FilmCollectionNFTModule } from './film-collection-nft/film-collection-nft.module'
import { WhitelistModule } from './whitelist/whitelist.module'
import { ALLOWED_DOMAINS } from './utils'
import { CloudinaryModule } from './cloudinary/cloudinary.module'
import { CloudinaryService } from './cloudinary/cloudinary.service'

Expand Down
4 changes: 2 additions & 2 deletions src/cloudinary/cloudinary.resolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { FileInterceptor } from '@nestjs/platform-express';
import { FileUpload, GraphQLUpload } from 'graphql-upload-ts';
@InputType()
class FileUploadInput {
@Field(() => GraphQLUpload)
file: FileUpload;
@Field(()=> UseInterceptors(FileInterceptor('file')))
file: Express.Multer.File;
}
@Resolver()
export class CloudinaryResolver {
Expand Down
4 changes: 2 additions & 2 deletions src/cloudinary/cloudinary.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { FileUpload } from 'graphql-upload-ts';

export class CloudinaryService {
async uploadImage(
file: FileUpload,
file: Express.Multer.File,
): Promise<UploadApiResponse | UploadApiErrorResponse> {

return new Promise((resolve, reject) => {
Expand All @@ -16,7 +16,7 @@ export class CloudinaryService {
resolve(result);
});

toStream(file.createReadStream()).pipe(upload);
toStream(file.buffer).pipe(upload);
});
}
}

0 comments on commit 56e20cf

Please sign in to comment.