feat: add MinIO file storage service with upload and download capabilities#11
Merged
c121914yu merged 10 commits intolabring:mainfrom Jun 25, 2025
Merged
feat: add MinIO file storage service with upload and download capabilities#11c121914yu merged 10 commits intolabring:mainfrom
c121914yu merged 10 commits intolabring:mainfrom
Conversation
Contributor
sd0ric4
commented
Jun 24, 2025
- Updated package.json to include MinIO and UUID dependencies.
- Created config.ts for file storage configuration, including max file size, retention days, and MinIO credentials.
- Implemented service.ts to handle file uploads, downloads, and metadata management using MinIO.
- Added upload.ts to support various file input types (network, local, base64, buffer) for uploading files.
- Introduced Zod schemas for input validation and structured response handling.
- Implemented logging for connection tests, bucket initialization, and error handling.
…ities - Updated package.json to include MinIO and UUID dependencies. - Created config.ts for file storage configuration, including max file size, retention days, and MinIO credentials. - Implemented service.ts to handle file uploads, downloads, and metadata management using MinIO. - Added upload.ts to support various file input types (network, local, base64, buffer) for uploading files. - Introduced Zod schemas for input validation and structured response handling. - Implemented logging for connection tests, bucket initialization, and error handling.
c121914yu
reviewed
Jun 24, 2025
c121914yu
reviewed
Jun 24, 2025
c121914yu
reviewed
Jun 24, 2025
c121914yu
reviewed
Jun 24, 2025
c121914yu
reviewed
Jun 24, 2025
c121914yu
reviewed
Jun 24, 2025
c121914yu
reviewed
Jun 24, 2025
c121914yu
reviewed
Jun 24, 2025
- Removed legacy upload.ts file and migrated its logic to a new S3-based implementation. - Introduced new configuration and controller files for S3 integration. - Implemented file upload service with support for multiple input types (network, local, base64, buffer). - Added validation schemas using Zod for input and output. - Created worker support for file service initialization and upload handling. - Enhanced logging for better traceability during file operations.
c121914yu
reviewed
Jun 25, 2025
c121914yu
reviewed
Jun 25, 2025
c121914yu
reviewed
Jun 25, 2025
c121914yu
reviewed
Jun 25, 2025
c121914yu
reviewed
Jun 25, 2025
src/s3/controller.ts
Outdated
| await this.ensureInitialized(); | ||
|
|
||
| if (fileBuffer.length > this.config.maxFileSize) { | ||
| throw new Error(`File size ${fileBuffer.length} exceeds limit ${this.config.maxFileSize}`); |
c121914yu
reviewed
Jun 25, 2025
| fileBuffer, | ||
| fileBuffer.length, | ||
| { | ||
| 'Content-Type': 'application/octet-stream', // 强制下载,不预览 |
Contributor
There was a problem hiding this comment.
这个会导致覆盖原来的 content type 么
c121914yu
reviewed
Jun 25, 2025
src/s3/controller.ts
Outdated
|
|
||
| const metadata = await this.uploadFile(buffer, filename); | ||
| const inputType = validatedInput.url | ||
| ? 'network' |
c121914yu
reviewed
Jun 25, 2025
c121914yu
reviewed
Jun 25, 2025
c121914yu
reviewed
Jun 25, 2025
c121914yu
reviewed
Jun 25, 2025
src/s3/controller.ts
Outdated
| } | ||
| await this.setBucketDownloadOnly(); | ||
| } catch (error) { | ||
| addLog.error('Failed to initialize bucket:', error); |
c121914yu
reviewed
Jun 25, 2025
src/s3/controller.ts
Outdated
| addLog.error('Failed to initialize bucket:', error); | ||
| if (error instanceof Error && error.message.includes('Method Not Allowed')) { | ||
| addLog.warn('Method Not Allowed - bucket may exist with different permissions'); | ||
| return; |
c121914yu
reviewed
Jun 25, 2025
src/s3/controller.ts
Outdated
| // ================================ | ||
|
|
||
| // 创建默认的文件服务实例 | ||
| export const fileService = new FileService(); |
Contributor
There was a problem hiding this comment.
全局存一个实例。
worker 里传实例进去看能不能用
Contributor
There was a problem hiding this comment.
系统初始化就增加 minio 实例化流程:
const file = new Fileserver()
await file.initBucket()
c121914yu
reviewed
Jun 25, 2025
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.