简体   繁体   中英

curl command to upload file to form

I'm trying to build a curl command that will upload my xpi to validation at Mozilla Add-on Validator .

I've captured the traffic with fiddler to see what the site is doing and try to mimic it's behavior from curl.

I've seen whats the post url, and tried curl https://addons.mozilla.org/en-US/developers/standalone-upload --form 'upload=@path-to-xpi.xpi' and also with csrfmiddlewaretoken=@path-to-xpi.xpi . And also tried adding the Content-Type .

This is the raw data from the first request:

POST https://addons.mozilla.org/en-US/developers/standalone-upload HTTP/1.1 Host: addons.mozilla.org Connection: keep-alive Content-Length: 41021 Origin: https://addons.mozilla.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryI0LeCjkeJnsfGipU Accept: */* Referer: https://addons.mozilla.org/en-US/developers/addon/validate Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8,he;q=0.6 Cookie: _ga=GA1.2.710702590.1450107779; sessionid=".eJyrVkouLkqLL8nPTs1TslLKznAOTYzI8czOTEzxCTe0SCzKichONjMO8PUO9Q5wcVfSUYpPLC3JiC8tTi2Kz0xRsjI0MrCwNDE3QZFISkwGmgeUVQJxi_Wg_GI9x9z8UKCIE1QeqKk4tbg4Mz8vPrWiILOoEmyepZmBQS0Aqsk0IA:1aLYVj:cbZQtNCkFRasDdFtJKI9b_WB6GA" POST https://addons.mozilla.org/en-US/developers/standalone-upload HTTP/1.1 Host: addons.mozilla.org Connection: keep-alive Content-Length: 41021 Origin: https://addons.mozilla.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.111 Safari/537.36 Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryI0LeCjkeJnsfGipU Accept: */* Referer: https://addons.mozilla.org/en-US/developers/addon/validate Accept-Encoding: gzip, deflate Accept-Language: en-US,en;q=0.8,he;q=0.6 Cookie: _ga=GA1.2.710702590.1450107779; sessionid=".eJyrVkouLkqLL8nPTs1TslLKznAOTYzI8czOTEzxCTe0SCzKichONjMO8PUO9Q5wcVfSUYpPLC3JiC8tTi2Kz0xRsjI0MrCwNDE3QZFISkwGmgeUVQJxi_Wg_GI9x9z8UKCIE1QeqKk4tbg4Mz8vPrWiILOoEmyepZmBQS0Aqsk0IA:1aLYVj:cbZQtNCkFRasDdFtJKI9b_WB6GA" ------WebKitFormBoundaryI0LeCjkeJnsfGipU Content-Disposition: form-data; name="csrfmiddlewaretoken" ------WebKitFormBoundaryI0LeCjkeJnsfGipU Content-Disposition: form-data; name="csrfmiddlewaretoken" khCUaXlIkiadLW18arlXkc63PMKUKPDG ------WebKitFormBoundaryI0LeCjkeJnsfGipU Content-Disposition: form-data; name="upload"; filename="extension.xpi" Content-Type: application/octet-stream khCUaXlIkiadLW18arlXkc63PMKUKPDG ------WebKitFormBoundaryI0LeCjkeJnsfGipU Content-Disposition: form-data; name="upload"; filename="extension.xpi" Content-Type: application/octet-stream

Currently I'm receiving an html page with Not allowed.

What am I missing? What else should I add to the request to receive a good response?

Thanks

Not resolving the curl upload command thing, but the original problem - validate an xpi through command line.

Validating an xpi through command line

This can be achieved with the addons-linter by Mozilla, which was in its early stages when this question was asked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM