programing

Wget으로 요청을 게시 하시겠습니까?

kingscode 2021. 1. 15. 08:25
반응형

Wget으로 요청을 게시 하시겠습니까?


wget을 사용하여 인증 토큰 'AUTH_1624582364932749DFHDD'를 사용하여 'test'폴더에 먼 서버에 사진을 업로드하고 싶습니다.

이 명령은 작동하지 않으며 (권한 부여 실패) 구문에 관한 것이 아닌지 확인하고 싶습니다.

wget --post-file=nature.jpg http://ipadress:8080/v1/AUTH_test/test/ --post-data="AUTH_1624582364932749DFHDD"

어떤 제안?


Wget은 현재 x-www-form-urlencoded 데이터 만 지원합니다. --post-file파일을 양식 첨부 파일로 전송하기위한 것이 아니라 다음과 같은 형식의 데이터를 예상합니다 key=value&otherkey=example.

--post-data--post-file같은 방식으로 작동 : 유일한 차이점은 즉 --post-data명령 행의 데이터를 지정할 수 있습니다 동안 --post-file당신이 보낼 수있는 데이터가 들어있는 파일의 경로를 지정할 수 있습니다.

다음은 문서입니다.

 --post-data=string
       --post-file=file
           Use POST as the method for all HTTP requests and send the specified data
           in the request body.  --post-data sends string as data, whereas
           --post-file sends the contents of file.  Other than that, they work in
           exactly the same way. In particular, they both expect content of the
           form "key1=value1&key2=value2", with percent-encoding for special
           characters; the only difference is that one expects its content as a
           command-line parameter and the other accepts its content from a file. In
           particular, --post-file is not for transmitting files as form
           attachments: those must appear as "key=value" data (with appropriate
           percent-coding) just like everything else. Wget does not currently
           support "multipart/form-data" for transmitting POST data; only
           "application/x-www-form-urlencoded". Only one of --post-data and
           --post-file should be specified.

인증 토큰과 관련하여 헤더, URL 경로 또는 데이터 자체에 제공되어야합니다. 이는 귀하가 사용하는 서비스 문서의 어딘가에 표시되어야합니다. GET 요청에서와 같이 POST 요청에서 키와 값을 사용하여 데이터를 지정해야합니다. 이렇게하면 서버가 특정 이름을 가진 여러 정보를받을 수 있습니다. 변수와 비슷합니다.

따라서 서버에 매직 토큰을 보낼 수 없으며 키 이름도 지정해야합니다. 키가 "토큰"이면이어야합니다 token=YOUR_TOKEN.

wget --post-data 'user=foo&password=bar' http://example.com/auth.php

또한 curl을 사용하여 파일을 보내는 것이 더 쉽기 때문에 가능하면 curl을 사용하는 것이 좋습니다. 인터넷에는 많은 예가 있습니다.

참조 URL : https://stackoverflow.com/questions/17699666/post-request-with-wget

반응형