[android-developers] Re: httpclient multipart form upload

2009-08-04 Thread cocoaghost

Thanks for the shortcut.

On Jul 31, 4:18 pm, Julien Dupouy  wrote:
> Hey,
>
> Instead of including the jars files you can use the http multipart
> classes defined in android but declared as internal, so you cannot use
> them directly, you have to download them from the android source code
> (http://android.git.kernel.org/?p=platform/frameworks/
> base.git;a=tree;f=core/java/com/android/internal/http/
> multipart;hb=54b6cfa9a9e5b861a9930af873580d6dc20f773c) and add them to
> your project. Some basics modifications must be performed before using
> them, nothing difficult (change the packages name, remove all logger
> calls). It works perfectly for me.
>
> I hope this could help somebody,
>
> Julien.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-07-31 Thread Julien Dupouy

Hey,

Instead of including the jars files you can use the http multipart
classes defined in android but declared as internal, so you cannot use
them directly, you have to download them from the android source code
(http://android.git.kernel.org/?p=platform/frameworks/
base.git;a=tree;f=core/java/com/android/internal/http/
multipart;hb=54b6cfa9a9e5b861a9930af873580d6dc20f773c) and add them to
your project. Some basics modifications must be performed before using
them, nothing difficult (change the packages name, remove all logger
calls). It works perfectly for me.

I hope this could help somebody,

Julien.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-07-14 Thread John Smith
2009/7/14 jottos 

>
> So, figured this out, and you were not too far from the answer.
> Our router was hanging up the requests that were going outbound and
> then back into our internal staging server.
> No idea why, but once we understood that and pointed the app at an
> external server, or used cellular connections everything works


Did you try the apache code, did it work at all, or did it fail too?

this one was up there on the pain scale
>

Aren't all corner cases that take a lot of time on the pain scale? :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-07-14 Thread jottos

So, figured this out, and you were not too far from the answer.
Our router was hanging up the requests that were going outbound and
then back into our internal staging server.
No idea why, but once we understood that and pointed the app at an
external server, or used cellular connections everything works

this one was up there on the pain scale


On Jul 13, 7:46 pm, John Smith  wrote:
> 2009/7/13 jottos 
>
> > Is there any setup android requires to make a post/multipart file
> > upload work that you didn't specify in your example?
> > On Jun 26, 8:53 pm, Delta Foxtrot  wrote:
>
> Nope I copied the code from an actual application I have working, the
> difference might be the servers we're communicating with. The great thing
> about standards is there is so many to pick from :)
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-07-13 Thread John Smith
2009/7/13 jottos 

> Is there any setup android requires to make a post/multipart file
> upload work that you didn't specify in your example?
> On Jun 26, 8:53 pm, Delta Foxtrot  wrote:
>

Nope I copied the code from an actual application I have working, the
difference might be the servers we're communicating with. The great thing
about standards is there is so many to pick from :)

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-07-13 Thread jottos

Hey Delta Foxtrot,

I agree with you on rolling your own. I've got a multipart form upload
class that populates form and uploads data (in this case picture),
however in android this code just doesn't work. It works every time
from any other java client - never fails, but on android, it looks
like it writes to the connection and then when you go to read the
response, it hangs, times out and the response code is
-1

I've looked at your code and it seems I'm doing everything you are
doing now (I added a user agent for grins) but no joy. All of the
HttpGets I do (restful calls) on android to may service work great,
but the post and MPF, not so much...

Is there any setup android requires to make a post/multipart file
upload work that you didn't specify in your example?

thanks
jos


On Jun 26, 8:53 pm, Delta Foxtrot  wrote:
> As I said, multipart uploads aren't hard to do your own function for.
>
>     private void UploadFile(String FileName)
>     {
>     try
>     {
>         String lineEnd = "\r\n";
>         String twoHyphens = "--";
>         String boundary =  "*MyMultiPartBoundary";
>
>         File sdcard = Environment.getExternalStorageDirectory();
>         File mydir = new File(sdcard, "MyFileDir");
>         File file = new File(mydir, FileName);
>
>         FileInputStream fileInputStream = new FileInputStream(file);
>
>         String UPLOADSCRIPT_URL = 
> "http://www.example.com/upload.php?username=example&password=example";;
>         System.out.println("Opening: "+UPLOADSCRIPT_URL);
>         URL url = new URL(UPLOADSCRIPT_URL);
>         HttpURLConnection conn = (HttpURLConnection)url.openConnection();
>
>         conn.setDoInput(true);
>         conn.setDoOutput(true);
>         conn.setUseCaches(false);
>
>                 conn.setRequestMethod("POST");
>                 conn.setRequestProperty("User-Agent",
> "MyExampleApp/"+appversion);
>                 conn.setRequestProperty("Content-Type",
> "multipart/form-data;boundary="+boundary);
>                 conn.connect();
>                 DataOutputStream dos = new
> DataOutputStream(conn.getOutputStream());
>                 dos.writeBytes(twoHyphens + boundary + lineEnd);
>                 dos.writeBytes("Content-Disposition: form-data;
> name=\"uploadedfile\";filename=\""+
>                                     FileName+"\"" + lineEnd);
>                 dos.writeBytes(lineEnd);
>
>                 int bytesAvailable;
>
>                 while((bytesAvailable = fileInputStream.available()) > 0)
>                 {
>                     int bufferSize = Math.min(bytesAvailable, 4096);
>                     byte[] buffer = new byte[bufferSize];
>                     int bytesRead = fileInputStream.read(buffer, 0,
> bufferSize);
>                     dos.write(buffer, 0, bytesRead);
>                 }
>
>                 dos.writeBytes(twoHyphens + boundary + twoHyphens +
> lineEnd);
>                 fileInputStream.close();
>                 dos.flush();
>                 dos.close();
>                 DataInputStream dis = new
> DataInputStream(conn.getInputStream());
>                 byte[] data = new byte[1024];
>                 len = dis.read(data, 0, 1024);
>                 dis.close();
>                 int respcode = conn.getResponseCode();
>                 System.out.println("done uploading! resp code = "+respcode);
>                 String respstr = "FAILED";
>                 if(len > 0)
>                     respstr = new String(data, 0, len);
>
>                 if(respcode == 200 && respstr.equals("OK"))
>             System.out.println("Uploaded "+FileName+" successfully!");
>         else
>             System.out.println("Upload Error: respcode="+respcode+",
> respstr="+respstr);
>     } catch (Exception e) {
>         System.out.println("upload error: "+e.toString());
>     }
>
>
>
> }

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-26 Thread Delta Foxtrot
As I said, multipart uploads aren't hard to do your own function for.

private void UploadFile(String FileName)
{
try
{
String lineEnd = "\r\n";
String twoHyphens = "--";
String boundary =  "*MyMultiPartBoundary";

File sdcard = Environment.getExternalStorageDirectory();
File mydir = new File(sdcard, "MyFileDir");
File file = new File(mydir, FileName);

FileInputStream fileInputStream = new FileInputStream(file);

String UPLOADSCRIPT_URL = "
http://www.example.com/upload.php?username=example&password=example";;
System.out.println("Opening: "+UPLOADSCRIPT_URL);
URL url = new URL(UPLOADSCRIPT_URL);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();

conn.setDoInput(true);
conn.setDoOutput(true);
conn.setUseCaches(false);

conn.setRequestMethod("POST");
conn.setRequestProperty("User-Agent",
"MyExampleApp/"+appversion);
conn.setRequestProperty("Content-Type",
"multipart/form-data;boundary="+boundary);
conn.connect();
DataOutputStream dos = new
DataOutputStream(conn.getOutputStream());
dos.writeBytes(twoHyphens + boundary + lineEnd);
dos.writeBytes("Content-Disposition: form-data;
name=\"uploadedfile\";filename=\""+
FileName+"\"" + lineEnd);
dos.writeBytes(lineEnd);

int bytesAvailable;

while((bytesAvailable = fileInputStream.available()) > 0)
{
int bufferSize = Math.min(bytesAvailable, 4096);
byte[] buffer = new byte[bufferSize];
int bytesRead = fileInputStream.read(buffer, 0,
bufferSize);
dos.write(buffer, 0, bytesRead);
}

dos.writeBytes(twoHyphens + boundary + twoHyphens +
lineEnd);
fileInputStream.close();
dos.flush();
dos.close();
DataInputStream dis = new
DataInputStream(conn.getInputStream());
byte[] data = new byte[1024];
len = dis.read(data, 0, 1024);
dis.close();
int respcode = conn.getResponseCode();
System.out.println("done uploading! resp code = "+respcode);
String respstr = "FAILED";
if(len > 0)
respstr = new String(data, 0, len);

if(respcode == 200 && respstr.equals("OK"))
System.out.println("Uploaded "+FileName+" successfully!");
else
System.out.println("Upload Error: respcode="+respcode+",
respstr="+respstr);
} catch (Exception e) {
System.out.println("upload error: "+e.toString());
}
}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-26 Thread slk

Hi Urs,

Download HttpClient binary from here: http://hc.apache.org/downloads.cgi
; be sure to download the distribution under the heading 'binary with
distribution'. After extracting, you will find a number of jars in the
lib folder.

saad

On Jun 10, 9:08 am, Urs Grob  wrote:
> Yes, I also couldn't find the jars for httpmime. I just created a jar from
> the sources and included that in the project.
>
> If anybody knows of some official jar, then I'd also like to know where I
> could get it (also to stay up to date)
>
> Thanks
> -- Urs
>
> On Wed, Jun 10, 2009 at 3:43 AM, Jason Proctor 
> wrote:
>
>
>
> > a kind soul has forwarded the jars on. community rules.
>
> > --
> > jason.software.particle

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-26 Thread slk

http://www.mirrorservice.org/sites/ftp.apache.org/httpcomponents/httpclient/binary/httpcomponents-client-4.0-beta2-bin-with-dependencies.tar.gz
Extract and the lib folder contains all relevant jars,
regards,
saad

On Jun 10, 9:08 am, Urs Grob  wrote:
> Yes, I also couldn't find the jars for httpmime. I just created a jar from
> the sources and included that in the project.
>
> If anybody knows of some official jar, then I'd also like to know where I
> could get it (also to stay up to date)
>
> Thanks
> -- Urs
>
> On Wed, Jun 10, 2009 at 3:43 AM, Jason Proctor 
> wrote:
>
>
>
> > a kind soul has forwarded the jars on. community rules.
>
> > --
> > jason.software.particle

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-26 Thread Delta Foxtrot
2009/6/26 gard 

>
> I got my jars from:
>
> http://hc.apache.org/downloads.cgi
>
> The dependencies are included in the "Binary with dependencies"
> download.
>
> regards,
>
> gard
>
> On 10 Jun, 10:08, Urs Grob  wrote:
> > Yes, I also couldn't find the jars for httpmime. I just created a jar
> from
> > the sources and included that in the project.
> >
> > If anybody knows of some official jar, then I'd also like to know where I
> > could get it (also to stay up to date)
>

It's not hard to make your own code for this and it saves quite a bit of
space by not including those jar files.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-26 Thread gard

I got my jars from:

http://hc.apache.org/downloads.cgi

The dependencies are included in the "Binary with dependencies"
download.

regards,

gard

On 10 Jun, 10:08, Urs Grob  wrote:
> Yes, I also couldn't find the jars for httpmime. I just created a jar from
> the sources and included that in the project.
>
> If anybody knows of some official jar, then I'd also like to know where I
> could get it (also to stay up to date)
>
> Thanks
> -- Urs
>
> On Wed, Jun 10, 2009 at 3:43 AM, Jason Proctor 
> wrote:
>
>
>
> > a kind soul has forwarded the jars on. community rules.
>
> > --
> > jason.software.particle
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-10 Thread Urs Grob
Yes, I also couldn't find the jars for httpmime. I just created a jar from
the sources and included that in the project.

If anybody knows of some official jar, then I'd also like to know where I
could get it (also to stay up to date)

Thanks
-- Urs

On Wed, Jun 10, 2009 at 3:43 AM, Jason Proctor wrote:

>
> a kind soul has forwarded the jars on. community rules.
>
>
> --
> jason.software.particle
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-09 Thread Jason Proctor

a kind soul has forwarded the jars on. community rules.


-- 
jason.software.particle

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-09 Thread Jason Proctor

Urs Grob wrote --

HttpClient 4 doesn't have that included anymore. The upstream project
didn't integrate it from the 3.x client.
I had to do exactly the same today. Basically I solved it by including
some additional jars:
mime4j
httpmime
This question was already on the list and there's some better explanation:
http://groups.google.com/group/android-developers/msg/1ea124b384da9dc2
-- Urs

thanks for the response.

my problem is that while i know what i have to include, i can't find 
a sensible download link for httpmime. the page points back to 
httpcore for downloads, but of course it's not in there any more (i 
checked). i was up for compiling it, but the source link takes me to 
the javadoc! something is definitely screwed up.

and thanks to yet more android-developer list weirdness, i'm not 
seeing posts at all at the moment (insert multiple sighs here). so if 
someone has the the httpmime and mime4j jars, or a good download 
location, and wouldn't mind sending them along, that would be just 
dandy.

ta muchly,
-- 
jason.software.particle

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---



[android-developers] Re: httpclient multipart form upload

2009-06-04 Thread Urs Grob

HttpClient 4 doesn't have that included anymore. The upstream project
didn't integrate it from the 3.x client.

I had to do exactly the same today. Basically I solved it by including
some additional jars:

mime4j
httpmime

This question was already on the list and there's some better explanation:

http://groups.google.com/group/android-developers/msg/1ea124b384da9dc2

-- Urs

On Tue, Jun 2, 2009 at 11:20 PM, Jason Proctor wrote:
>
> i'm trying to do multipart form upload using the 4.x httpclient on
> android. all the 4.x code samples i'm seeing use
> org.apache.http.entity.mime.MultipartEntity, but i'm running into a
> roadblock trying to find it.
>
> it's supposed to be in the httpmime project, but the download link
> for that project leads me back to httpcore, and the httpcore download
> doesn't contain that class.
>
> anyone else get multipart form upload to work?
>
> thanks
> --
> jason.software.particle
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~--~~~~--~~--~--~---