Hi,

I'm trying to upload files to Picasa from the client's browser (using 
javascript and/or jquery). The following two approaches have been taken, 
though neither help:-

1) The following html followed by the javascript

<form id="data" method="post" enctype="multipart/form-data" 
action="https://picasaweb.google.com/data/feed/api/user/*USERID*/albumid/*
ALBUMID*" target="_blank">
   
    <input name="image" type="file" />
    <button onclick="OnSubmitHit()">Submit</button>
</form>

function OnSubmitHit() {      
            
            var url = 'https://picasaweb.google.com/data/entry/api/user/*
USERID*/albumid/*ALBUMID*';

            req = CreateXmlHttpObject();

            req.onreadystatechange = handleResponse;
            req.open("POST", url, true);

            var formData = new FormData(document.getElementById("data"));

            req.setRequestHeader('Slug', "Test.jpg");

            req.setRequestHeader('Authorization', 'Bearer ' + 
n_AuthResultToken);
            req.setRequestHeader('Content-Type', 'image/jpeg');

            req.send(formData);
        }

This returns "415 Unsupported Media Type" error and this is response 
"Content-Type 
multipart/form-data;boundary=---------------------------325751823621709 is 
not a valid input type.".

2) Replacing the javascript by jquery like this (the OnSubmitHit funtion 
needs to be removed):-


$(document).ready(function () {
            $("form#data").submit(function () {
              
                var formData = new FormData($(this)[0]);             
                $.ajax({
                   
                    data: formData,
                   
                    headers: {                       
                        'Authorization': 'Bearer ' + n_AuthResultToken
                    },
                    beforeSend: function (xhr) {                        
                        xhr.setRequestHeader('Authorization', 'Bearer ' + 
n_AuthResultToken);
                        xhr.setRequestHeader('Slug', 'Test.jpg');
                    },
                    error: function (data) {
                        debugger;
                        alert("error" + data.request)
                    },                    
                    complete: function (xhr, status) {
                        debugger;
                        alert("complete" + data.request)
                    },                   
                });
                alert("postAjax");
                return false;
            });
        });

Here, the browser continues to process the POST request for a long while 
and ultimately shows the "Connection Established" message, but no image is 
uploaded in Picasa.

Any ideas how to make this work?

-- 
You received this message because you are subscribed to the Google Groups 
"Google Picasa Web Albums API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-picasa-data-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to