X-Git-Url: https://git.plutz.net/?p=rawnet;a=blobdiff_plain;f=page_video.sh;fp=page_video.sh;h=28061c2e18f458aa32ae8d9ab6badb7ba05dc21a;hp=587ee526f18e0b1b72d7043c990519756e02538b;hb=74cc921e6bcc52387f4e652f0d95f67eb9edfd50;hpb=abe43467796699b21501e922247c4eaf681ee273 diff --git a/page_video.sh b/page_video.sh index 587ee52..28061c2 100755 --- a/page_video.sh +++ b/page_video.sh @@ -1,41 +1,10 @@ #!/bin/sh . "$_EXEC/db_video.sh" +. "$_EXEC/upload.sh" read_video "$video" -UPLOAD(){ - local file="$1" - local boundary line length=0 - - [ ! "${CONTENT_TYPE}" -o "${CONTENT_TYPE##multipart/form-data;*}" ] && return 1 - - boundary="${CONTENT_TYPE#*; boundary=}" - boundary="${boundary%%;*}" - - while read -r line; do - length="$(( length + ${#line} + 1))" - [ "${line%${CR}}" = "--$boundary" ] && break - done - while read -r line; do - length="$(( length + ${#line} + 1))" - [ ! "${line%${CR}}" ] && break \ - || debug "$line" - done - - printf "%i\n" "$(( CONTENT_LENGTH - length ))" >"${file}.upload" - head -c "$(( CONTENT_LENGTH - length ))" \ - | sed -nE ' - # print lines until boundary ( = actual file upload) - :FILE; p; n; - /^--'"${boundary}"'(--)?\r?$/!bFILE; - # discard remaining lines - :END; $q; n; bEND; - ' >"$file" - truncate -s $(( $(stat -c %s -- "$file") -2 )) -- "$file" - rm -- "${file}.upload" -} - [ "$REQUEST_METHOD" = POST ] && case "$(POST action)" in update_video) if [ ! "$USER_ID" ]; then @@ -79,6 +48,7 @@ if [ "$REQUEST_METHOD" = POST -a "$channel" -a "$video" ]; then elif UPLOAD "$_DATA/$channel/$video.mp4"; then update_video "$video" status=private VIDEO_STATUS=private + REDIRECT "${_BASE}/channel/${channel}/${video}/edit" fi fi @@ -110,72 +80,7 @@ if [ "$channel" -a "$video" -a "$action" = edit ]; then elif [ "$channel" -a "$video" -a "$action" = frameuploadprogress ]; then AUTHOR || REDIRECT "$_BASE/$channel/$video/#ERROR_EDIT_NOTALLOWED" printf '%s\r\n' 'Content-Type: text/html' 'Connection: close' '' - printf ' -
-