BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 05-28-2008, 08:49 PM   #1 (permalink)
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8330
PIN: N/A
Carrier: Telus
Posts: 26
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default HttpConnection file size limit?

Please Login to Remove!

I am trying to write a podcatcher/media player. I've been able to download a small mp3 file (~150kb) but when I tried with a larger file it downloaded 1kb of something and returned a response code of 400. Is this a file size limit imposed by the MDS server?

If so, is there any way to chunk the file into segments smaller than the size limit and piece it back together locally?
Offline  
Old 05-29-2008, 12:05 AM   #2 (permalink)
New Member
 
Join Date: Apr 2008
Location: Pune, India
Model: 8830
PIN: N/A
Carrier: Sprint
Posts: 12
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you trying to download the file via a direct URL or via a web service that serves files?

I have been successful in downloading files around 2 or 3 MB via direct URL.

As far as chunking goes, there are no standard APIs available. You would have to use bytestream and by grabbing content from the InputStream, write the data to file.

~Aniket
Offline  
Old 05-29-2008, 07:14 AM   #3 (permalink)
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8330
PIN: N/A
Carrier: Telus
Posts: 26
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am downloading from a URL.

Here is the code I am using:

Code:
public static void downloadWebData(final String url, final String fileName) throws IOException {
	Thread t = new Thread(new Runnable() {
		public void run() {
			HttpConnection connection = null;
			InputStream inputStream = null;
			OutputStream o = null;
			FileConnection fconn = null;

			try {
				// Initialize Input
				connection = (HttpConnection) Connector.open(url, Connector.READ, true);
				inputStream = connection.openInputStream();
				
				// Initialize Output
				fconn = (FileConnection)Connector.open(fileName, Connector.READ_WRITE);
				if(!fconn.exists()) {
					fconn.create();
				}
				o = fconn.openOutputStream();
				
				byte[] responseData = new byte[10000];
				int length = 0;
				while (-1 != (length = inputStream.read(responseData))) {
					o.write(responseData, 0, length);
				}
				int responseCode = connection.getResponseCode();
				if (responseCode != HttpConnection.HTTP_OK) {
					throw new IOException("HTTP response code: "
								+ responseCode);
				}
			}
			catch (IOException e) {
				e.printStackTrace();
			}
			catch (final Exception ex) {
				System.out.println("Could not download file!");
			}
			finally {
				try {
					inputStream.close();
					inputStream = null;
					connection.close();
					connection = null;
					o.close();
					fconn.close();
				}
				catch(Exception e){}
			}
		}
	});
	t.start();
}
I tried using
setRequestProperty("Content-Length", "byte 0-1000/1001");
before openInputStream so it would only download a part of the file, but it seems to be ignored.

Last edited by Massif : 05-29-2008 at 08:26 AM.
Offline  
Old 07-11-2008, 03:11 AM   #4 (permalink)
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: pearl
PIN: N/A
Carrier: none
Posts: 20
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

i also encounter the same problem with the file size !
Offline  
Old 09-26-2008, 06:07 AM   #5 (permalink)
New Member
 
Join Date: Jan 2007
Model: 8320
Carrier: Airtel
Posts: 4
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Download File Size Limit

Quote:
Originally Posted by Massif View Post
I am trying to write a podcatcher/media player. I've been able to download a small mp3 file (~150kb) but when I tried with a larger file it downloaded 1kb of something and returned a response code of 400. Is this a file size limit imposed by the MDS server?

If so, is there any way to chunk the file into segments smaller than the size limit and piece it back together locally?
Hi,
I am also facing the same problem in downloading file of large size.Did you get any solution for that ?

Thanks a lot.

Kamal
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LQQK PHILIPS ADVANCE BALLAST NEMA PREMIUM CENTIUM - ICN-2P32-N
$18.99
LQQK PHILIPS ADVANCE BALLAST NEMA PREMIUM CENTIUM - ICN-2P32-N pictureAdvance Ballast Icn-4P32-N F32T8Bulbs
$18.0
Advance Ballast Icn-4P32-N F32T8Bulbs pictureUniversal Ballast slim design 443-L-SLH-TC-P input 277 volts 60HZ 9 1/4" long
$34.83
Universal Ballast slim design 443-L-SLH-TC-P input 277 volts 60HZ 9 1/4Advance Ballast Postline 74P2832011 100W Mercury H38/H44 227 V 60HZ instructions
$49.83
Advance Ballast Postline 74P2832011 100W Mercury H38/H44 227 V 60HZ instructions picturePhilips & Sylvania high pressure sodium bulbs 100 watts C100S54 & 67578 ballast
$29.83
Philips & Sylvania high pressure sodium bulbs 100 watts C100S54 & 67578 ballast picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.