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


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

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

Forum Jump


1pcs used TSXMFPP128K Memory Card picture

1pcs used TSXMFPP128K Memory Card

$175.00



FOMI Extra Thick Firm Coccyx Orthopedic Memory Foam Seat Cushion (Black) picture

FOMI Extra Thick Firm Coccyx Orthopedic Memory Foam Seat Cushion (Black)

$71.99



Fadal PCB-0042 RAM Memory Expansion 4 MEG MB 1460-4A picture

Fadal PCB-0042 RAM Memory Expansion 4 MEG MB 1460-4A

$595.00



1PC NEW Memory card 2711-NM15 NEW picture

1PC NEW Memory card 2711-NM15 NEW

$347.78



NEW Original Allen Bradley 2080-MEMBAK-RTC Memory Module With RTC Plug-In picture

NEW Original Allen Bradley 2080-MEMBAK-RTC Memory Module With RTC Plug-In

$283.73



Dental Endodontic Endo Memory Engine Rotary Root Canal NiTi File 25mm files 6PCS picture

Dental Endodontic Endo Memory Engine Rotary Root Canal NiTi File 25mm files 6PCS

$349.50







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