Bash에서 cURL을 사용하여 공식 클라이언트 외부에서 업로드 할 수있는 답변을 찾았지만 XMLHttpRequest를 사용하여 JavaScript로 변환하는 데 어려움이 있습니다. 주요 문제는 Puush가 CORS를 지원한다고 생각하지 않는다는 것입니다. 여기 내 관련 코드는 지금까지의 :웹 서버에서 Puush에 파일을 업로드하는 방법은 무엇입니까?
var xml = new XMLHttpRequest(),
fd = new FormData();
xml.open("POST", "http://puush.me/api/up", true);
xml.withCredentials = true; //I've tried with and without this line, neither seems to work
//the following variables are specified from cURL demos I found
fd.append("z", "poop"); //I honestly don't get this part
fd.append("e", "[email protected]");
fd.append("k", apiKey); //which I copied from my account settings on Puush
fd.append("f", input.files[0]); //where "input" is <input type="file"/>
//add event handlers
xml.addEventListener("progress", progress);
xml.addEventListener("load", loaded);
xml.addEventListener("error", error);
xml.addEventListener("abort", aborted);
xml.send(fd); //send the FormData as a "multipart/form-data" request
난 항상 서버가 응답하지 않았다고 말하는 콘솔에서 오류 로그와 상관없이 항상 오류 처리기가 호출되는 내가 무엇을 시도하고 동일한 응답을 얻을
Access-Control-Allow-Origin: http://localhost
(예 : null 원점도 거부되었으므로 file : // 프로토콜을 사용하지 않았습니다.)
편집 : 원래 bash는 코드는 다음 링크에서 확인할 수 있습니다
http://pastebin.com/ZnbY91EA
https://github.com/nekodex/lazymode/blob/master/puush/puu.sh
https://github.com/blha303/puush-linux/blob/master/puush
https://github.com/NickHu/puush-linux/blob/master/puush
귀하의 의견을 보내 주셔서 감사합니다. 그러나 나는 이미 "CORS의 본질 때문에 응답이 거절되었다"고 축 어적으로 언급했다. 또한 GomuPuush 서비스 대신 자체 서버를 사용했으며, 내 대답에 아직 답을하지 않은 질문에 대한 답변을 귀하의 답변이 추가하지 않는다고 생각합니다. –