try
This commit is contained in:
parent
216198ea8a
commit
9b34046aca
1 changed files with 25 additions and 26 deletions
51
inotify.sh
51
inotify.sh
|
@ -16,8 +16,8 @@ inotifywait -m /out -e close_write |
|
||||||
|
|
||||||
# Überprüfen, ob die Datei existiert
|
# Überprüfen, ob die Datei existiert
|
||||||
if [ ! -f "$file_path" ]; then
|
if [ ! -f "$file_path" ]; then
|
||||||
echo "Fehler: Datei $file_path existiert nicht."
|
echo "Fehler: Datei $file_path existiert nicht."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Dateigröße ermitteln
|
# Dateigröße ermitteln
|
||||||
|
@ -26,33 +26,32 @@ inotifywait -m /out -e close_write |
|
||||||
|
|
||||||
# Datei in Chunks hochladen
|
# Datei in Chunks hochladen
|
||||||
i=0
|
i=0
|
||||||
while [ $i -lt $num_chunks ]; do
|
while [ $i -lt $num_chunks ]
|
||||||
# Temporäre Datei für den Chunk
|
do
|
||||||
temp_chunk_file="/tmp/chunk_$i"
|
# Temporäre Datei für den Chunk
|
||||||
|
temp_chunk_file="/tmp/chunk_$i"
|
||||||
|
|
||||||
# Chunk erstellen
|
# Chunk erstellen
|
||||||
dd if="$file_path" bs=$chunk_size skip=$i count=1 of="$temp_chunk_file" 2>/dev/null
|
dd if="$file_path" bs=$chunk_size skip=$i count=1 of="$temp_chunk_file" 2>/dev/null
|
||||||
|
|
||||||
# Überprüfen, ob der Chunk erfolgreich erstellt wurde
|
# Überprüfen, ob der Chunk erfolgreich erstellt wurde
|
||||||
if [ -f "$temp_chunk_file" ]; then
|
if [ -f "$temp_chunk_file" ]
|
||||||
# Chunk hochladen
|
then
|
||||||
curl --location "$UPLOAD_URL" \
|
# Chunk hochladen
|
||||||
--header "Authorization: Bearer $AUTH_TOKEN" \
|
curl --location "$UPLOAD_URL" \
|
||||||
--form "recording_id=${file%.mp4}" \
|
--header "Authorization: Bearer $AUTH_TOKEN" \
|
||||||
--form "chunk_index=${i}" \
|
--form "recording_id=${file%.mp4}" \
|
||||||
--form "total_chunks=${num_chunks}" \
|
--form "chunk_index=${i}" \
|
||||||
--form "file=@$temp_chunk_file"
|
--form "total_chunks=${num_chunks}" \
|
||||||
|
--form "file=@$temp_chunk_file"
|
||||||
|
|
||||||
# Temporäre Datei löschen
|
# Temporäre Datei löschen
|
||||||
rm "$temp_chunk_file"
|
rm "$temp_chunk_file"
|
||||||
else
|
else
|
||||||
echo "Fehler beim Erstellen des Chunks $i"
|
echo "Fehler beim Erstellen des Chunks $i"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Inkrementieren des Chunk-Zählers
|
# Inkrementieren des Chunk-Zählers
|
||||||
i=$(( i + 1 ))
|
i=$(( i + 1 ))
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
Loading…
Add table
Reference in a new issue