-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
205 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,18 +12,14 @@ const SEED_USER = 'Admin' | |
|
||
const defaultUser: Prisma.UserCreateInput = { | ||
uuid: generateUUID(), | ||
username: 'BruceSong', | ||
email: '[email protected]', | ||
username: 'Admin', | ||
password: '$2b$10$kZEDiHCgDhFmX7/sKwYm1ORMK99FNk/QQgebcwBflKrAWKGA.D46W', | ||
name: 'Bruce Song', | ||
firstName: 'Bruce', | ||
lastName: 'Song', | ||
name: 'Admin', | ||
gender: Gender.UNDEFINED, | ||
phoneNumber: randPhoneNumber(), | ||
birthDate: randPastDate(), | ||
address: randFullAddress(), | ||
avatarUrl: randAvatar(), | ||
biography: 'I am a Web developer.', | ||
verified: true, | ||
enabled: true, | ||
roles: Array.of(Role.ADMIN), | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import type { Request, Response, Router } from 'express' | ||
import express from 'express' | ||
import { readFileSync } from 'fs' | ||
|
||
import { UploadService } from '@/services/upload' | ||
import { upload } from '@/shared' | ||
import type { BaseResponse } from '@/types' | ||
|
||
const router: Router = express.Router() | ||
|
||
router.get('/', (request: Request, response: Response) => { | ||
const file = readFileSync('storage/images/a278294ea9942307a598d89ba88f572a', { encoding: 'utf8' }) | ||
console.log(file) | ||
response.set('content-type', 'image/png') | ||
response.status(200).send(file) | ||
}) | ||
|
||
router.post('/', upload.single('file'), async (request: Request, response: BaseResponse<any>) => { | ||
const { file } = request | ||
if (!file) { | ||
response.status(400).json({ | ||
message: 'File is required.' | ||
}) | ||
return | ||
} | ||
|
||
UploadService.logFileInfo(file) | ||
|
||
response.json({ | ||
data: file | ||
}) | ||
}) | ||
|
||
router.post('/batch', upload.array('files'), async (request: Request, response: BaseResponse<string>) => { | ||
const { files } = request | ||
|
||
console.log(files) | ||
response.json({ | ||
data: '' | ||
}) | ||
}) | ||
|
||
export default router |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from './upload.models' | ||
export * as UploadService from './upload.services' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export type UploadFileInfo = { | ||
mimetype: string | ||
originalname: string | ||
size: string | ||
path: string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// export const processUploadFile = async (file: File): Promise<Upload> => {} | ||
|
||
export const logFileInfo = (file: Express.Multer.File) => { | ||
const { mimetype, originalname, size, path } = file | ||
console.log('Mime Type: %s', mimetype) | ||
console.log('Original Name: %s', originalname) | ||
console.log('File Size: %s', size) | ||
console.log('File Path: %s', path) | ||
} |
Oops, something went wrong.