2013-07-17 10 views
37

मैं प्रमाणीकरण टोकन का उपयोग करके एक दूरस्थ सर्वर पर एक तस्वीर अपलोड करने के लिए wget का उपयोग करना चाहता हूं: 'AUTH_1624582364932749DFHDD' 'परीक्षण' फ़ोल्डर में।Wget के साथ पोस्ट अनुरोध?

इस आदेश काम नहीं करता है (प्राधिकरण विफल) और मुझे यकीन है कि यह वाक्य रचना के बारे में नहीं है बनाना चाहते:

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

कोई सुझाव?

उत्तर

54

man wget का कहना है:

--post-डेटा और --post-फ़ाइल का केवल एक निर्दिष्ट किया जाना चाहिए।

पूर्ण अनुच्छेद है:

--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. 

विशेष रूप से यह कहा है:

--post-फ़ाइल प्रपत्र संलग्नक के रूप में फ़ाइलों को प्रसारित करने के लिए नहीं है: उन के रूप में "कुंजी दिखाई देना चाहिए = मान "डेटा

संपादित करें: आपको "कुंजी = मान" डेटा के सिद्धांत को समझना होगा। एक POST अनुरोध में, जैसा कि एक GET अनुरोध में है, आपको कुंजी और मानों का उपयोग करके डेटा निर्दिष्ट करना होगा। इस प्रकार सर्वर विशिष्ट नामों के साथ कई सूचनाएं प्राप्त करने में सक्षम होगा। यह चर के समान है।

इसलिए, आप सर्वर पर एक जादू टोकन नहीं भेज सकते हैं, आपको कुंजी का नाम निर्दिष्ट करने की भी आवश्यकता है। यदि कुंजी "टोकन" है, तो यह token=YOUR_TOKEN होना चाहिए।

इसके अलावा, आपको कर्ल का उपयोग करने पर विचार करना चाहिए यदि आप कर सकते हैं क्योंकि इसका उपयोग करके फाइलें भेजना आसान है। इसके लिए इंटरनेट पर कई उदाहरण हैं।

+0

मैं इस मामले में अपना लेख टोकन कैसे भेज सकता हूं? – Dady

+0

यदि यह एक मूल HTML फॉर्म था, तो आप टोकन वाले इनपुट का नाम कैसे देंगे? क्योंकि यह होना चाहिए: टोकन = AUTH_1624582364932749DFHDD –

+0

@Dady: 'curl' का उपयोग करें? – Hasturkun

संबंधित मुद्दे