Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
maap-s3-laptop
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esa-common
maap-s3-laptop
Commits
b51e6a4a
Commit
b51e6a4a
authored
4 years ago
by
kosted
Browse files
Options
Downloads
Patches
Plain Diff
add download by chunck
parent
444f3272
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
maap-s3.py
+18
-3
18 additions, 3 deletions
maap-s3.py
with
18 additions
and
3 deletions
maap-s3.py
+
18
−
3
View file @
b51e6a4a
...
...
@@ -293,9 +293,9 @@ def download(path, name):
if
location
:
#We download the data using the location
print
(
"
[INFO] we are about to download the data
"
)
response
=
requests
.
get
(
location
)
open
(
name
,
'
wb
'
).
write
(
response
.
content
)
download_file
(
location
,
name
)
#
response = requests.get(location)
#
open(name, 'wb').write(response.content)
print
(
"
[INFO] Download finished
"
)
else
:
...
...
@@ -303,6 +303,21 @@ def download(path, name):
##########################
# download file using url #
##########################
def
download_file
(
url
,
name
):
#local_filename = url.split('/')[-1]
# NOTE the stream=True parameter below
with
requests
.
get
(
url
,
stream
=
True
)
as
r
:
r
.
raise_for_status
()
with
open
(
name
,
'
wb
'
)
as
f
:
for
chunk
in
r
.
iter_content
(
chunk_size
=
8192
):
# If you have chunk encoded response uncomment if
# and set chunk_size parameter to None.
#if chunk:
f
.
write
(
chunk
)
return
name
##########################
# list data in s3 folder #
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment