I need some help here. I have been working on an android game where some information about your progress is sent to the server. Also you neeed to record your voice and the game will sent to our blobstore at my google server.
I managed to use Jsoup to upload a form to my datastore.
My problem is i ahve been trying to upload stuff in various ways to the file upload app that i did. No success.
This is my Google APP code (python). It works perfectly on my browser and it's meant to upload files to my blobstore. Basically it's an http file POST form
import os
import urllib
from google.appengine.ext import blobstore
from google.appengine.ext import webapp
from google.appengine.ext.webapp import blobstore_handlers
from google.appengine.ext.webapp import template
from google.appengine.ext.webapp.util import run_wsgi_app
class MainHandler(webapp.RequestHandler):
def get(self):
upload_url = blobstore.create_upload_url('/upload')
self.response.out.write('<html><body>')
self.response.out.write('<form action="%s" method="POST" enctype="multipart/form-data">' % upload_url)
self.response.out.write("""Upload File: <input type="file" name="file"><br> <input type="submit" name="submit" value="Submit"> </form></body></html>""")
class UploadHandler(blobstore_handlers.BlobstoreUploadHandler):
def post(self):
upload_files = self.get_uploads('file')
blob_info = upload_files[0]
self.response.out.write('success!')
#self.redirect('/')
app= webapp.WSGIApplication(
[('/', MainHandler),
('/upload', UploadHandler),
], debug=True)
This is the code i have been trying to use to upload stuff to it. This code is run on my andorid phone.
public static void sendF(File file)
{
if (file.exists())
{
Log.e("msg", "exists");
}
else
{
Log.e("msg", "does not exists");
}
String url = "http://MYAPP.appspot.com/";
HttpClient httpclient = AndroidHttpClient.newInstance("MyGame");
HttpPost httpost = new HttpPost(url);
MultipartEntity entity = new MultipartEntity();
entity.addPart("file", new FileBody(file));
httpost.setEntity(entity);
HttpResponse response;
try {
response = httpclient.execute(httpost);
Log.e("internet", EntityUtils.toString(response.getEntity()));
} catch (ClientProtocolException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
problem is: I keep getting this
05-29 17:10:52.369: E/internet(1720): <h1>405 Method Not Allowed</h1>
05-29 17:10:52.369: E/internet(1720): The method POST is not allowed for this resource. <br /><br />
(Although I am able to use it from a web browser. Can someone help me? (sorry if I am not clear)