Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
RecopilacionParametrosVideoTransferenciaArchivos
Overview
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
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Antonio Benítez Cortés
RecopilacionParametrosVideoTransferenciaArchivos
Commits
398c6434
Commit
398c6434
authored
May 28, 2026
by
Antonio Benítez Cortés
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add new file
parent
76994f56
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
63 additions
and
0 deletions
+63
-0
Transfer.py
+63
-0
No files found.
Transfer.py
0 → 100644
View file @
398c6434
import
requests
from
pathlib
import
Path
import
sys
# -- CONFIG ---------------------------------------------
KADI_URL
=
"https://192.168.128.44/api/biaprint/folder"
TOKEN
=
"pat_ef2df043911631d9c43d4e9846062843c8708e44925b55f3"
# Cambiar token cuando cambies el usuario
# Carpeta a enviar (puedes pasarla como argumento)
FOLDER
=
Path
(
sys
.
argv
[
1
])
if
len
(
sys
.
argv
)
>
1
else
Path
(
"/home/pi/session"
)
# -- VALIDACIONES ---------------------------------------
if
not
FOLDER
.
exists
()
or
not
FOLDER
.
is_dir
():
print
(
f
" Carpeta no valida: {FOLDER}"
)
sys
.
exit
(
1
)
# -- PREPARAR FILES -------------------------------------
files
=
[]
for
p
in
FOLDER
.
rglob
(
"*"
):
if
p
.
is_file
():
rel_path
=
p
.
relative_to
(
FOLDER
)
files
.
append
(
(
"files[]"
,
(
str
(
rel_path
),
open
(
p
,
"rb"
)))
)
print
(
f
" Enviando {len(files)} archivos desde {FOLDER}..."
)
# -- REQUEST --------------------------------------------
try
:
response
=
requests
.
post
(
KADI_URL
,
headers
=
{
"Authorization"
:
f
"Bearer {TOKEN}"
},
data
=
{
"folder_name"
:
FOLDER
.
name
},
files
=
files
,
verify
=
False
# pon True si usas HTTPS valido
)
print
(
f
" Status: {response.status_code}"
)
try
:
print
(
" Respuesta JSON:"
)
print
(
response
.
json
())
except
Exception
:
print
(
" Respuesta texto:"
)
print
(
response
.
text
)
except
Exception
as
e
:
print
(
f
" Error enviando datos: {e}"
)
finally
:
# cerrar archivos
for
_
,
(
_
,
f
)
in
files
:
f
.
close
()
\ No newline at end of file
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