Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
pdf-miner
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Qin Kaijie
pdf-miner
Commits
1c74ed8e
Unverified
Commit
1c74ed8e
authored
Apr 10, 2024
by
drunkpig
Committed by
GitHub
Apr 10, 2024
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14 from papayalove/master
更新了io s3ReaderWriter
parents
ce1a04f2
5473f32a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
13 deletions
+10
-13
S3ReaderWriter.py
magic_pdf/io/S3ReaderWriter.py
+10
-13
No files found.
magic_pdf/io/S3ReaderWriter.py
View file @
1c74ed8e
...
...
@@ -9,21 +9,18 @@ from botocore.config import Config
class
S3ReaderWriter
(
AbsReaderWriter
):
def
__init__
(
self
,
s3_profile
):
self
.
client
=
self
.
_get_client
(
s3_profi
le
)
def
__init__
(
self
,
ak
:
str
,
sk
:
str
,
endpoint_url
:
str
,
addressing_style
:
str
):
self
.
client
=
self
.
_get_client
(
ak
,
sk
,
endpoint_url
,
addressing_sty
le
)
def
_get_client
(
self
,
s3_profile
):
ak
,
sk
,
end_point
,
addressing_style
=
parse_aws_param
(
s3_profile
)
def
_get_client
(
self
,
ak
:
str
,
sk
:
str
,
endpoint_url
:
str
,
addressing_style
:
str
):
s3_client
=
boto3
.
client
(
service_name
=
"s3"
,
aws_access_key_id
=
ak
,
aws_secret_access_key
=
sk
,
endpoint_url
=
end
_point
,
endpoint_url
=
end
point_url
,
config
=
Config
(
s3
=
{
"addressing_style"
:
addressing_style
},
retries
=
{
'max_attempts'
:
5
,
'mode'
:
'standard'
}),
)
return
s3_client
def
read
(
self
,
s3_path
,
mode
=
"text"
,
encoding
=
"utf-8"
):
bucket_name
,
bucket_key
=
parse_bucket_key
(
s3_path
)
...
...
@@ -51,13 +48,13 @@ class S3ReaderWriter(AbsReaderWriter):
if
__name__
==
"__main__"
:
# Config the connection info
profile
=
{
'ak'
:
''
,
'sk'
:
''
,
'endpoint'
:
''
}
ak
=
""
sk
=
""
endpoint_url
=
""
addressing_style
=
""
# Create an S3ReaderWriter object
s3_reader_writer
=
S3ReaderWriter
(
profi
le
)
s3_reader_writer
=
S3ReaderWriter
(
ak
,
sk
,
endpoint_url
,
addressing_sty
le
)
# Write text data to S3
text_data
=
"This is some text data"
...
...
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