Problem: How to upload files to server

I'm a newbie to BB development. I have problems to download the file from my BB to the server.

Any help would be appreciated... Thank you...

Code of the thread:

class UploadThrd extends Thread
{
Limit string = "*";
String lineend = "\r\n";
String twoHyphens = "-";
int maxBufferSize = 0;
DataInputStream fileInputStream = null;
public void run()
{
try {}
FileConnection fis=(FileConnection)Connector.open("file:///store/home/user/newfile.txt");
CreateFileScreen.showMsg ("recovered file name");
InputStream inputStream = fis.openInputStream ();

ByteArrayOutputStream Bos = new ByteArrayOutputStream();
int buffersize = (int) fis.fileSize ();
ubyte [] buffer = new byte [buffersize];
int length = 0;
While ((length = InputStream.Read (buffer))! = - 1).
{
Bos.Write (buffer, 0, Length);
}
Byte [] b = bos.toByteArray ();
CreateFileScreen.showMsg ("copied file...");

ConnectionFactory connFact = new ConnectionFactory();
ConnectionDescriptor connDesc;
connDesc = connFact.getConnection ("http://www.myserver.net/z/upload.php");
If (connDesc! = null)
{
HttpConnection conn;
Conn = (HttpConnection) connDesc.getConnection ();
UiApplication.getUiApplication () .invokeLater (new Runnable()
{
public void run() {}
Dialog.Alert ("http connected...");
}
});
conn.setRequestMethod (HttpConnection.POST);
conn.setRequestProperty ("Content-Type", "multipart/form-data; limit = "" + limit); "
conn.setRequestProperty ("login", "Keep-Alive");
UiApplication.getUiApplication () .invokeLater (new Runnable()
{
public void run() {}
Dialog.Alert ("' HTTPConnection TOGETHER... verification response Code.. '");
}
});
conn.setRequestProperty ("Content-Length", Long.toString (b.length));
end of series

If (conn.getResponseCode () == HttpConnection.HTTP_OK)
{
UiApplication.getUiApplication () .invokeLater (new Runnable()
{
public void run() {}
Dialog.Alert ("response Code: HTTP_OK!");
}
});
OutputStream os = conn.openOutputStream ();
Write bytes
UiApplication.getUiApplication () .invokeLater (new Runnable()
{
public void run() {}
Dialog.Alert ("written bytes..");
}
});

String CT = "Content-Type: multipart/form-data;" limit = "+ limit;"
OS. Write ("Content-Disposition: form-data;") Name =-"source\" "." GetBytes());
OS. Write (LineEnd.GetBytes ());
OS. Write (LineEnd.GetBytes ());
OS. Write ("BlackBerry". GetBytes());
OS. Write (LineEnd.GetBytes ());

OS. Write (twoHyphens.GetBytes ());
OS. Write (Boundary.GetBytes ());
OS. Write (LineEnd.GetBytes ());

String filename = "z\newfile.txt; »
OS. Write ("Content-Disposition: form-data;") name =-"Filedata\"; filename =------"". GetBytes());
OS. Write (FileName.GetBytes ());
OS. Write("\"".) GetBytes());
OS. Write (LineEnd.GetBytes ());

OS. Write (CT. GetBytes());
OS. Write (LineEnd.GetBytes ());
OS. Write (LineEnd.GetBytes ());

OS. Write (b, 0, b.length);

OS. Write (LineEnd.GetBytes ());

OS. Write (twoHyphens.GetBytes ());
OS. Write (Boundary.GetBytes ());
OS. Write (twoHyphens.GetBytes ());
OS. Write (LineEnd.GetBytes ());
UiApplication.getUiApplication () .invokeLater (new Runnable()
{
public void run() {}
Dialog.Alert ("downloaded file!");
}
});
OS. Flush();
OS. Close();
}
on the other
UiApplication.getUiApplication () .invokeLater (new Runnable()
{
public void run() {}
Dialog.Alert ("no connection");
}
});
Conn.Close ();
}

}
catch (Exception e) {}
UiApplication.getUiApplication () .invokeLater (new Runnable()
{
public void run() {}
Dialog.Alert("===exception!");
}
});
}
}
}

Class app:

SerializableAttribute public class CreateFileApp extends UiApplication
{
/**
* Entry point for application
@param args command-line arguments (not used)
*/
Public Shared Sub main (String [] args)
{
Try
{
FileConnection fc = (FileConnection)Connector.open("file:///store/home/user/newfile.txt");
If (! fc.exists ())
{
FC. Create(); create the file if it doesn't exist
}
OutputStream outStream = fc.openOutputStream ();
outStream.write ("happy test".getBytes ());
outStream.close ();
FC. Close();
CreateFileScreen.showMsg ("I'll upload file..");
Thread UploadThrd = new UploadThrd();
thread. Start();
}
catch (IOException e)
{
System.out.println ("= IOException:"+ e.getMessage () ");
}
catch (Exception e1)
{
System.out.println ("= Exception:"+ e1.getMessage () ");
}
Create a new instance of the application and make the currently
who runs the thread of the application of the event dispatch thread.
PAP CreateFileApp = new CreateFileApp();
theApp.enterEventDispatcher ();
}

/**
* Creates a new CreateFileApp object
*/
public CreateFileApp()
{
Push a screen onto the stack in the user interface for rendering.
pushScreen (CreateFileScreen.cfs);
}
}

The screen class:

/ public final class CreateFileScreen extends screen
{
/**
* Creates a new CreateFileScreen object
*/
public static CreateFileScreen SFC = new CreateFileScreen();
public CreateFileScreen()
{
Set the displayed title of the screen
setTitle ("create a file");
}
public static void showMsg (String msg)
{
LabelField lbl = new LabelField (msg);
CFS. Add (LBL);
}
}

Hello, welcome to the Forums!

You must use the property tto line allow multi part download on your BB using Post server.

It is a good example in nokia Forums, where you can fashion it accordint to your settings & file Type.

http://www.developer.Nokia.com/community/wiki/HTTP_Post_multipart_file_upload_in_Java_ME

Thank you

Tags: BlackBerry Developers

Similar Questions

  • Please tell me how to upload files to my account from adobe of the computer public cloud storage

    Could you get it someone please let me know how to upload files to my cloud storage service account

    Hey kanavsood11,

    Please see the city KB doc link below to learn more on how to upload files to the cloud of document:

    Document help Cloud | Manage files

    Let me know if you need more assistance.

    Kind regards

    Ana Maria

  • How to upload files to the dashboard obiee 11 g

    Hello


    can someone explain how to upload files to the obiee dashboard.

    Thanks in advance...

    check out this link.
    http://total-bi.com/2011/02/external-files-OBIEE-dashboard/

  • Dreamweaver CS5 crashes after uploading files to server

    Dreamweaver CS5 - Windows 7 - all is well until I upload files to the server.  Then, if I stay logged in or not, if I try to open a page or a template, Dreamweaver crashes.

    I tried to restore preferences (by deleting the registry key), etc., but nothing seems to help.

    Any ideas?

    I just tried this and my problem seems to have disappeared!

    http://forums.Adobe.com/message/3615460#3615460

    ... name change

    c:\Program Files\Adobe\Adobe Dreamweaver CS4\configuration\Translators\ASP.Net.htm

    at ASP.Net.disable_htm

  • How to upload files to an ftp site?

    On Internet Explorer I can open an ftp with "File Explorer" site, and I can upload files to the site. However, on Firefox, I can't find this option. I need to upload files to an ftp for my work site, and Firefox does not allow me to do.

    Hello, G.F., upload to an FTP server is a feature that is not built - in the core firefox browser. You can use the excellent addon FireFTP however: https://addons.mozilla.org/firefox/addon/fireftp/

  • Automatically upload files to server on save does not (CS6)?

    Hello

    My workflow includes using a local test of Linux server. I noticed that by selecting the "automatically download files to the server when recording" box on our local test server does not download files on the test server when you press CTRL-s to save the current file. However, by pressing CTRL-SHIFT-u not uplaod the file very well.

    Anyone else notice that this function does not work or is this something else in my configurations?

    Thank you!

    I met the same problem in DreamWeaver CC 2015. The problem proved that auto-push save only works if you have the appropriate box selected for TWO tests server and remote server. If it is activated only for one, it won't do.

    Be extremely careful with this because you must ensure that you have selected in the files, the test server pane otherwise it will be auto-push on your production server!

    This bug must REALLY be resolved to prevent disasters...

  • How to upload files to iCloud drive without installing anything on my PC.

    I use a PC with Windows 7, and currently, I don't use Apple products.

    I have an iCloud account, and I wanted to add some files to iCloud drive and make room on my computer.

    How can I use my browser (Chrome) to add files to iCloud by car?

    When I go to https://www.icloud.com/#iclouddrive , it tells me to download the software. I don't want to download any software iCloud or sync with my computer, I just want to download my files to iCloud by car so I can make room on my computer.

    Thank you!

    I can't find any documentation from Apple that says clearly, but I suspect that there is a requirement first activate iCloud drive from an Apple device or iCloud for Windows. Once this has been done, you should be able to download directly using the link you posted (and I'm able to do).

    Note that iCloud is mainly oriented towards the synchronization of data between devices rather than having a storage cloud orientation only. There are other services that can be better adapted to your needs.

  • How to download files in mydomain_server_2

    Hi Experts,

    I have created java with 2 servers cs managed there in the clouds of the pub, at - it a way to download files, example: mydomain_server2.out server managed as not in the same box with the server administrator?

    And how to upload files to the server?

    Best regards

    Hello

    Yes, you can access other servers managed within your Cluster of JCS (not only the one who has the Server Admins exposed with public IP address) and move the files to/from it.

    Here are the high level steps:

    1. Copy your private ssh key to the administrator of the server (use opc user for the virtual computer and copy the key into the opc home folder)
    2. SSH on the administration as opc Server
    3. make sure that the private ssh key privileges are 600 (to avoid permissions errors)
    4. Open your account and browser oracle cloud you internal JCS of instance and while in the "View" tab, identify the host (virtual computer) within the cluster you want to access the search its host name, search for somehting like this "host:jcs101demo-wls-2" being the host name internal built based on the name of your instance of the JCS, wls - + the number of the node in the cluster
    5. now connect to your virtual machine now using the host when identifying the machine name, for example in the above case will be: ssh-i ssh_private_key opc@jcs101demo-wls-2

    So now you should be able to copy everything that you downloaded Admin Server to the managed server to which you have connected.

    In case you need more details, please see the oracle here.

    Hope that helps.

  • With the help of AUSST - latest updates of Adobe CC 2014 are not uploaded to the server - how to solve this problem?

    With the help of AUSST - latest updates of Adobe CC 2014 are not uploaded to the server - how to solve this problem?

    I tried both incremental and train to do a fresh install (. / AdobeUpdateServerSetupTool - root = "/ serverroot/updates / Adobe / CS '-fee)

    If anyone can answer this - please let me know.

    Hi Mark,

    Try to refresh the web server and run the AUSST with cool switch. In addition, please make sure that you have enough disk space available in the location of the server.

    Thank you

    Ashish

  • I can't delete some files that I uploaded to the server. What should I do?

    I can't delete some files that I uploaded to the server. I get a notice: FTP an error occurred - cannot delete the PDF download server folder. Operation failed. The directory is not empty, or there may be a permission problem.

    What should I do?

    Try to delete the files in your folder first.

    If there is a permissions problem on the server that you cannot delete files, you need to contact your Site Administrator (if you have one) or your Web hosting provider.

    Nancy O.

  • How to make it possible for clients to upload files to my Web site?

    How to make it possible for clients to upload files to my Web site?

    Thank you for posting.

    Muse is a design software. It does not provide you server for hosting your site. However, BusinessCatalyst not. So if you publish your site on BusinessCatalyst, you can allow upload of a file interface via Web Forms or Web applications. Please refer to the following article on how you can achieve in British Colombia through webapps: http://kb.worldsecuresystems.com/kb/add-custom-content-using-web.html

    See you soon,.

    Scott Raj Rouanet

  • Interleaving of Dreamweaver returns and the white spaces of files uploaded to my server

    Hello

    This same problem has been published here by several people about 5 months and never answered. I just upgraded to 10.7 and CS5.5 and I now have the same problem.

    Files downloaded using ftp in Dreamweaver have all formatting returns and whitespace removed from their part. The files are fine if they are uploaded via ftp using Fetch.

    When I view the source code of the uploaded file in my browser, all the code in the file is on a single line. This applies to JavaScript and HTML files. This stops the JS to work and causes the HTML will not display correctly.

    I went through the DW ftp settings advanced and experienced with on/off options. It doesn't change anything. I added some JS and HTML for writing, no effect exclusion list.

    I used an extra hard drive and did a clean install of 10.7 and 5.5 without change in the behavior of DW.

    Everything works perfectly using 10.4 and CS4.

    Any help would be appreciated.

    Thank you in advance.

    This is published periodically and as far as I know he is always answered.  But nevermind...

    The symptoms you describe are almost always related to incompatibility between the linebreak in the code type and the native type linebreak on the server.  Check your DW PREFERENCES and see that you specified under the Code Format > line break type:.  That must match the SERVER uses.

  • what object to use to write uploaded files to the server?

    Hello

    My question is trivial, but I do not know how to solve. I need to download file *.xml server on my cell phone and write it on the mobile. There are input/output streams to read/write. OK, but what I should write the file I've already read? byte [] table? but I don't know what should be the size... cause, I guess I can't write data directly on my mobile? If Yes, can someone suggest me how?

    concerning

    Oh God, I'm so stupid! It's so http:

    _httpConnection.setRequestMethod ("post");

    _httpConnection.getResponseCode ();

    works great!

    concerning

  • When I want to burn a CD in Windows Media Player, it shows "Windows Media Player has encountered a problem when burning the file to disk". What's wrong? How to fix?

    When I want to burn a CD in Windows Media Player, it shows "Windows Media Player has encountered a problem when burning the file to disk".    What's wrong? How to fix?

    I tried several times to remove the selection to burn and create a new a new but it keep "Windows Media Player has encountered a problem when burning the file to delivery" appears what should I do?   What problem is it?

    Hello

    1. what file format you are trying to burn?

    2. have you made changes on the computer recently?

    3. What is the security software installed on the computer?

    If it's something you downloaded, it may be copy protected by DRM, in which case you may not burn it to a CD or DVD.

    Here are a few things to try:

    1. make sure that the disc is clean.

    2. try a different brand of blank discs.

    3. stop all other programs that are running.

    4. make sure that the hard drive does not use disk compression.

    I suggest that you follow these steps and check if they help to solve the problem.

    Method 1:

    Try to use the Troubleshoot utility to see if that solves the problem.

    a. open the troubleshooting Windows Media Player settings Troubleshooter by clicking the Start button, then Control Panel.

    (b) in the search box, type "convenience store" and then click Troubleshooting.

    c. click on show all and then click the Windows Media Player settings.

    Method 2:

    Select a recording speed (write) more slow for the CD burner.

    Change settings for burning a CD or DVD in Windows Media Player

    http://Windows.Microsoft.com/en-us/Windows7/change-settings-for-burning-a-CD-or-DVD-in-Windows-Media-Player

    Method 3:

    If you have any third-party burning software, I suggest you temporarily Uninstall it and then try to burn the disc using Windows Media Player.

    Note: Reinstall the software after the trial.

    Method 4:

    Temporarily disable all programs that could activate themselves, while burning is in progress, such as screensavers or anti-virus programs.

    http://Windows.Microsoft.com/en-us/Windows7/turn-Windows-Firewall-on-or-off
    http://Windows.Microsoft.com/en-us/Windows7/disable-antivirus-software

    Note: Run the computer without antivirus software or firewall is a potential threat to the computer; Be sure to activate security software after completing the troubleshooting steps and after identifying the problem.

    I hope this helps.

  • Pole mi compare sempre questa written knew parecchi siti: some file sul Server essere essere o errati every. The cancellate hiding del browser e riprovate. SE he problem persists, contattate l'autore del sito Web.

    Some file sul Server essere essere o errati every. The cancellate hiding del browser e riprovate. SE he problem persists, contattate l'autore del sito Web.

    Pole compare sempre questa written form. Perhaps some widgets gli danno fastidio.

    Grazie

    Download your files published again and make sure you include everything, including all the scripts.

    Mylenium

Maybe you are looking for