On 9 April 2010 19:35, Anna Powell-Smith <annapowellsm...@googlemail.com>wrote:
> > > On 9 April 2010 18:19, Gubatron <gubat...@gmail.com> wrote: > >> I suppose when you say FilePart, you mean this >> >> org.apache.commons.httpclient.methods.multipart.FilePart >> >> I'm thinking along these lines after looking at that API (I haven't >> tested this) >> >> final File theFile = new File("yourFileLargerThan2Mb.ext"); >> >> //Implement your own PartSource to feed your File >> PartSource partSource = new PartSource() { >> //this should return a buffered reader... right? >> public InputStream createInputStream() { >> return BufferedInputStream (new FileInputStream(theFile)); >> } >> >> //implement the other methods of the interface >> public String getFileName() { >> return theFile.getName(); >> } >> >> public long getLength() { >> return theFile.length();// although this might be how much is >> left on the stream, not sure. >> } >> >> } >> >> FilePart part = FilePart(theFileName, partSource); >> >> then use your part on your multipart request. >> > > Thanks. Constructing a FilePart from a File is actually as easy as this, I > think - but do you think your method would provide some advantage? > > File temp_file = new File(Environment.getExternalStorageDirectory(), > "myfile.gif"); > FilePart vFile = new FilePart("fileupload", temp_file); > > As I say, this works for files of 50MB. The only reason I can't use it is > that I can't construct a File object from an Android content Uri. I have to > use an Android content Uri because that's what the video intent returns. > Ah. If I could transform my content Uri into FileInputStream (will have to experiment) then I could use your method. I can convert a content Uri to an InputStream already, so it'll just be getting from an InputStream to a FileInputStream that might be the challenge. I'll experiment. -- 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 To unsubscribe, reply using "remove me" as the subject.