BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 05-28-2008, 08:49 PM   #1
Massif
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8330
PIN: N/A
Carrier: Telus
Posts: 26
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
AniketAnikhindi
New Member
 
Join Date: Apr 2008
Location: Pune, India
Model: 8830
PIN: N/A
Carrier: Sprint
Posts: 12
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
Massif
Knows Where the Search Button Is
 
Join Date: May 2008
Model: 8330
PIN: N/A
Carrier: Telus
Posts: 26
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
smartmind
Knows Where the Search Button Is
 
Join Date: Jun 2008
Model: pearl
PIN: N/A
Carrier: none
Posts: 20
Default

i also encounter the same problem with the file size !
Offline  
Old 09-26-2008, 06:07 AM   #5
kamal.hasanjk
New Member
 
Join Date: Jan 2007
Model: 8320
Carrier: Airtel
Posts: 4
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250 picture

VINTAGE Bruker Board DEC W4P3042 for SpectroSpin 250

$99.99



Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16) picture

Dec/Adac Corp. D4-10390 Rev 6 Model 1664ATTL Output Pulse Board 1983 (B16)

$189.99



Original New DEC Digital DCJ11-AE 57-19400-09 Vintage CPU x 1pc picture

Original New DEC Digital DCJ11-AE 57-19400-09 Vintage CPU x 1pc

$100.00



Vintage Journal Beautiful Garden Flower Embossed Leather-Antique Handmade Dec... picture

Vintage Journal Beautiful Garden Flower Embossed Leather-Antique Handmade Dec...

$27.91



Niedermaier vintage Mannequins Visual Display Props Dec. 1991 Catalogue picture

Niedermaier vintage Mannequins Visual Display Props Dec. 1991 Catalogue

$141.00



HSS 12pcs Valve Seat & Face Cutter 45dec 30dec 20dec for Vintage Car, Bikes ,Jee picture

HSS 12pcs Valve Seat & Face Cutter 45dec 30dec 20dec for Vintage Car, Bikes ,Jee

$235.94







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