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