@echo off
CLS
REM For security reason dont write the real access_token
set "access_token=xxxxxxxxxxxxx"
set "video_id=818155814"
set "video_path=Prueba_INS.mp4"
set "file_name=Prueba_INS.mp4"
set "curl=C:\INFO_LOCAL_UL\CURL\bin\curl.exe"
set "jq=C:\INFO_LOCAL_UL\jq\jq-win64.exe"
:: Get the size of the video file in bytes
Echo Get the size of the video file in bytes
for %%I in ("%video_path%") do set "file_size=%%~zI"
Echo value of new video file_size: %file_size%
Echo.
:: Create a JSON payload for the POST request
Echo Create a JSON payload for the POST request
if exist payload.json del /F /Q payload.json
echo { "file_name": "%file_name%", "upload": { "status": "in_progress", "size": "%file_size%", "approach": "tus" } } > payload.json
Echo value of payload.json:
Type payload.json
Echo.
:: Send a POST request to /videos/{video_id}/versions
Echo Send a POST request to /videos/{video_id}/versions
if exist response.json del /F /Q response.json
%curl% -X POST "https://api.vimeo.com/videos/%video_id%/versions" --header "Content-Type: application/json" --header "Authorization: Bearer %access_token%" --header "Accept: application/vnd.vimeo.*+json;version=3.4" -d "@payload.json" -o response.json
:: Get the size of response.json file in bytes
Echo Get the size of response.json file in bytes
for %%I in ("response.json") do set "file_size_response=%%~zI"
:: Extract the upload link for the new video
Echo Extract the upload link for the new video
if exist upload_link.txt del /F /Q upload_link.txt
type response.json | %jq% ".upload.upload_link" -r > upload_link.txt
set /p upload_link=<upload_link.txt
Echo value of upload_link: %upload_link%
Echo.
:: upload for the new video
%curl% -X PATCH "%upload_link%" -H "Upload-Offset: 0" -H "Content-Type: application/offset+octet-stream" -H "Tus-Resumable: 1.0.0" -H "Upload-Length:%file_size%" --upload-file "%video_path%"
echo Video replaced successfully!
Get the size of the video file in bytes
value of new video file_size: 639475195
Create a JSON payload for the POST request
value of payload.json:
{ "file_name": "Prueba_INS.mp4", "upload": { "status": "in_progress", "size": "639475195", "approach": "tus" } }
Send a POST request to /videos/{video_id}/versions
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 15487 0 15374 100 113 2686 19 0:00:05 0:00:05 --:--:-- 4425
Get the size of response.json file in bytes
value of size for response.json: 15374
Extract the upload link for the new video
value of upload_link: https://us-files.tus.vimeo.com/files/vimeo-prod-src-tus-us/e4635cfd45043efef78b98bbc9a236ae
missing or invalid Upload-Length header
Video replaced successfully!
有人可以指导我解决此错误的原因和可能的解决方案。
url = "https://us-files.tus.vimeo.com/files/vimeo-prod-src-tus-us/479c393bd0bdea42c811eb6d4d5a6ead"
request = "PATCH"
header = "Upload-Offset: 0"
header = "Content-Type: application/offset+octet-stream"
header = "Tus-Resumable: 1.0.0"
header = "Upload-Length: 639475195"
upload-file = "Prueba_INS.mp4"
*------------
但是,我总是收到相同的错误消息:“上传长度标头丢失或无效”