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


2PC Camshaft Timing Solenoid Valve For 04-10 Ford F-150 Expedition 4.6L 5.4L VCT picture

2PC Camshaft Timing Solenoid Valve For 04-10 Ford F-150 Expedition 4.6L 5.4L VCT

$47.59



SA-3786-12 603350 Fuel Shutoff Solenoid Kubota Compatible 721D2 21HP Grasshopper picture

SA-3786-12 603350 Fuel Shutoff Solenoid Kubota Compatible 721D2 21HP Grasshopper

$29.99



Fuel Shut Off Solenoid Fit For Kubota D905 D1005 D1105 17208-60010 17208-60015 picture

Fuel Shut Off Solenoid Fit For Kubota D905 D1005 D1105 17208-60010 17208-60015

$25.25



Cole Hersee (24059-BP) 12V Insulated SPST Continuous Duty Solenoid picture

Cole Hersee (24059-BP) 12V Insulated SPST Continuous Duty Solenoid

$29.85



Starter Contactor Solenoid G056739 Fits for Generac Generator 12v 150A USA picture

Starter Contactor Solenoid G056739 Fits for Generac Generator 12v 150A USA

$44.19



1503ES-12A5UC5S SA-4569-T Fuel Shutoff Solenoid Compatible With Kubota picture

1503ES-12A5UC5S SA-4569-T Fuel Shutoff Solenoid Compatible With Kubota

$19.99







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