Droidme
Droidme

Reputation: 1252

Post an image to Picasa using Javascript XMLHttpRequest

I am trying to post an image to picasa using javascript. I have got the required tokens. But when I post, I get an error "204 no content"

Here is my code.

function send()
{
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function ()
{
if(xhr.readyState == 4)
alert(xhr.status);
}
xhr.open("POST","https://picasaweb.google.com/data/feed/api/user/default/albumid/default", true);
var type = document.getElementById('file').files[0].type;
xhr.setRequestHeader('Accept','message/x-jl-formresult');
xhr.setRequestHeader("content-type",type);
xhr.setRequestHeader('Content-Length',document.getElementById('file').files[0].size);
xhr.sendAsBinary(document.getElementById('file').files[0].getAsBinary());

}

Upvotes: 2

Views: 992

Answers (2)

lance
lance

Reputation: 53

The problem is with dojo.xhrget, not with your syntax or picasa. Look in the net panel in firebug and you'll see that dojo.xhrGet does not send the session cookie in the request header s that picasa requires.

Try using jQuery.Get and you'll find it works fine.

Upvotes: 1

epascarello
epascarello

Reputation: 207501

Do you know what 204 means?

204 No Content The server successfully processed the request, but is not returning any content

http status codes

The server is saying it was good and there is nothing to return.

Upvotes: 2

Related Questions