Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CamTrap-Hub
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
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
Code review analytics
Issue analytics
Insights
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
Yan Tung Lam
CamTrap-Hub
Merge requests
!10
update download functions
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
update download functions
dev
into
main
Overview
0
Commits
1
Pipelines
0
Changes
9
Merged
Yan Tung Lam
requested to merge
dev
into
main
9 months ago
Overview
0
Commits
1
Pipelines
0
Changes
9
Expand
0
0
Merge request reports
Compare
main
main (base)
and
latest version
latest version
e85e5a99
1 commit,
9 months ago
9 files
+
72
−
33
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
9
Search (e.g. *.vue) (Ctrl+P)
appstore/routes/cameraTrapTools.py
+
22
−
10
Options
@@ -214,13 +214,19 @@ def autocopy_download():
if
file_path
.
strip
():
try
:
file_data
,
_
=
container
.
get_archive
(
file_path
)
file_content
=
io
.
BytesIO
()
# Create a temporary BytesIO to hold the tar data
tar_data
=
io
.
BytesIO
()
for
chunk
in
file_data
:
file_content
.
write
(
chunk
)
file_content
.
seek
(
0
)
tar_data
.
write
(
chunk
)
tar_data
.
seek
(
0
)
# add file to zip
zip_file
.
writestr
(
file_path
.
replace
(
f
"
{
target_path
}
/
"
,
""
),
file_content
.
getvalue
())
# Extract the file from the tar archive
with
tarfile
.
open
(
fileobj
=
tar_data
,
mode
=
'
r
'
)
as
tar
:
member
=
tar
.
next
()
# Get the first (and only) file
file_content
=
tar
.
extractfile
(
member
).
read
()
# Add the extracted file content to the zip
zip_file
.
writestr
(
file_path
.
replace
(
f
"
{
target_path
}
/
"
,
""
),
file_content
)
except
docker
.
errors
.
NotFound
:
print
(
f
"
File not found in the container:
{
file_path
}
"
)
except
docker
.
errors
.
APIError
as
e
:
@@ -253,13 +259,19 @@ def create_video_download():
if
file_path
.
strip
():
try
:
file_data
,
_
=
container
.
get_archive
(
file_path
)
file_content
=
io
.
BytesIO
()
# Create a temporary BytesIO to hold the tar data
tar_data
=
io
.
BytesIO
()
for
chunk
in
file_data
:
file_content
.
write
(
chunk
)
file_content
.
seek
(
0
)
tar_data
.
write
(
chunk
)
tar_data
.
seek
(
0
)
# add file to zip
zip_file
.
writestr
(
file_path
.
replace
(
f
"
{
target_path
}
/
"
,
""
),
file_content
.
getvalue
())
# Extract the file from the tar archive
with
tarfile
.
open
(
fileobj
=
tar_data
,
mode
=
'
r
'
)
as
tar
:
member
=
tar
.
next
()
# Get the first (and only) file
file_content
=
tar
.
extractfile
(
member
).
read
()
# Add the extracted file content to the zip
zip_file
.
writestr
(
file_path
.
replace
(
f
"
{
target_path
}
/
"
,
""
),
file_content
)
except
docker
.
errors
.
NotFound
:
print
(
f
"
File not found in the container:
{
file_path
}
"
)
except
docker
.
errors
.
APIError
as
e
:
Loading