Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
F
Falcon
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Walter Huang
Falcon
Commits
a842861c
Commit
a842861c
authored
Jan 14, 2026
by
Haohao Jiang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: rename upload method name
parent
8781869c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
11 deletions
+23
-11
.env.example
.env.example
+15
-0
README.md
README.md
+2
-2
s3.ts
src/clients/s3.ts
+6
-9
No files found.
.env.example
0 → 100644
View file @
a842861c
BOBCAT_HOST=xxxxxxxxx
BOBCAT_USER_COOKIE=xxxxxxxxx
DESIGN_TEAM_CHANNEL_ID=xxxxxxxxx
GOOGLE_SERVICE_ACCOUNT_KEY_FILE=xxxxxxxxx
GOOGLE_SHEET_AI_ID=xxxxxxxxx
GOOGLE_SHEET_ID=xxxxxxxxx
GSHEET_AI_DELAY_MS=xxxxxxxxx
SLACK_WEBHOOK=xxxxxxxxx
# AWS S3 Configuration
AWS_REGION=ap-northeast-1
AWS_ACCESS_KEY_ID=your_access_key_id
AWS_SECRET_ACCESS_KEY=your_secret_key
AWS_S3_BUCKET_NAME=your_bucket_name
\ No newline at end of file
README.md
View file @
a842861c
...
...
@@ -31,9 +31,9 @@ AWS_S3_BUCKET_NAME=your_bucket_name
### 使用示例
```
typescript
import
{
upload
FileFromEnv
}
from
'./src/clients/s3'
;
import
{
upload
ToS3
}
from
'./src/clients/s3'
;
const
key
=
await
upload
FileFromEnv
(
const
key
=
await
upload
ToS3
(
'/path/to/local/file.pdf'
,
'uploads/file.pdf'
,
{
contentType
:
'application/pdf'
,
acl
:
'private'
}
...
...
src/clients/s3.ts
View file @
a842861c
...
...
@@ -3,10 +3,10 @@
*
* 使用示例:
* ```typescript
* import { upload
FileFromEnv
} from './clients/s3';
* import { upload
ToS3
} from './clients/s3';
*
* // 上传文件(自动读取环境变量)
* const key = await upload
FileFromEnv
(
* const key = await upload
ToS3
(
* '/path/to/file.pdf',
* 'uploads/file.pdf',
* { contentType: 'application/pdf', acl: 'private' }
...
...
@@ -15,8 +15,7 @@
*/
import
{
S3Client
,
PutObjectCommand
}
from
'@aws-sdk/client-s3'
;
import
{
createReadStream
,
statSync
}
from
'fs'
;
import
{
basename
}
from
'path'
;
import
{
readFileSync
}
from
'fs'
;
/**
* S3 Configuration
...
...
@@ -64,14 +63,12 @@ export async function uploadFile(
options
?:
UploadOptions
):
Promise
<
string
>
{
const
client
=
createS3Client
(
config
);
const
fileStream
=
createReadStream
(
filePath
);
const
fileStat
=
statSync
(
filePath
);
const
fileContent
=
readFileSync
(
filePath
);
const
uploadParams
:
any
=
{
Bucket
:
config
.
bucketName
,
Key
:
key
,
Body
:
fileStream
,
ContentLength
:
fileStat
.
size
,
Body
:
fileContent
,
};
if
(
options
?.
contentType
)
{
...
...
@@ -99,7 +96,7 @@ export async function uploadFile(
* @param options Upload options
* @returns The S3 object key
*/
export
async
function
upload
FileFromEnv
(
export
async
function
upload
ToS3
(
filePath
:
string
,
key
:
string
,
options
?:
UploadOptions
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment