Getting extra things in the uploaded file by flex file upload

Hi,
I am working on a application where I am using adobe flex. I
have a requirement wher I have to upload file to the server. System
allows user to browse file from local machine and flex uploads it
to the server.
Now there is a upload url, its a jsp page which gets
mutipart/form-data content from the request, opens an outputstream
and writes the content of the inputstrem to the file.
fileUpload.mxml
quote:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="
http://www.adobe.com/2006/mxml"
layout="vertical" creationComplete="initApp()">
<mx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.utils.ObjectUtil;
import flash.events.*;
import flash.net.FileReference;
import flash.net.URLRequest;
private var fileRef:FileReference;
private function initApp():void {
fileRef = new FileReference();
fileRef.addEventListener(Event.CANCEL, traceEvent);
fileRef.addEventListener(Event.COMPLETE, completeEvent);
fileRef.addEventListener(Event.SELECT, selectEvent);
fileRef.addEventListener(IOErrorEvent.IO_ERROR, traceEvent);
fileRef.addEventListener(Event.OPEN, traceEvent);
fileRef.addEventListener(ProgressEvent.PROGRESS,
progressEvent);
fileRef.addEventListener(SecurityErrorEvent.SECURITY_ERROR,
traceEvent);
private function traceEvent(event:Event):void {
var tmp:String = "================================\n";
//ta.text += tmp + event.type + " event:" +
mx.utils.ObjectUtil.toString(event) + "\n" ;
//ta.verticalScrollPosition += 20;
private function ioErrorEvent(event:IOErrorEvent):void{
Alert.show("IOError:" + event.text);
traceEvent(event);
private function selectEvent(event:Event):void{
btn_upload.enabled = true;
traceEvent(event);
filename.text = fileRef.name;
progressBar.setProgress(0, 100);
progressBar.label = "Loading 0%";
private function progressEvent(event:ProgressEvent):void {
progressBar.setProgress(event.bytesLoaded,
event.bytesTotal);
traceEvent(event);
private function completeEvent(event:Event):void {
progressBar.label = "Complete.";
filename.text += " uploaded";
traceEvent(event);
btn_upload.enabled = false;
btn_cancel.enabled = false;
private function uploadFile(endpoint:String):void {
var param:String = "author=" + ti_author.text;
var req:URLRequest = new URLRequest(endpoint);
req.method = URLRequestMethod.POST;
fileRef.upload(req, param, false);
progressBar.label = "Uploading...";
btn_cancel.enabled = true;
]]>
</mx:Script>
<mx:Panel title="Flex 2 File Uploading Demo" width="100%"
height="100%" >
<mx:Form>
<mx:FormItem label="Upload URL:">
<mx:TextInput editable="false" id="uploadURL"
width="100%" text="
http://localhost/flexApp/jsps/upload.jsp"
enabled="true" />
</mx:FormItem>
<mx:FormItem label="Selected File:">
<mx:Label id="filename"/>
</mx:FormItem>
<mx:FormItem label="Upload By:">
<mx:TextInput id="ti_author" text="Author" />
</mx:FormItem>
<mx:FormItem direction="horizontal" width="100%">
<mx:Button width="80" label="Browse"
click="fileRef.browse()" />
<mx:Button width="80" label="Upload" id="btn_upload"
enabled="false" click="uploadFile(uploadURL.text)" />
<mx:Button width="80" label="Cancel" id="btn_cancel"
enabled="false" click="fileRef.cancel()" />
</mx:FormItem>
<mx:HRule width="100%" tabEnabled="false"/>
<mx:FormItem label="Progress:">
<mx:ProgressBar id="progressBar" mode="manual" />
</mx:FormItem>
</mx:Form>
</mx:Panel>
</mx:Application>
test.jsp page
quote:
InputStream is = null;
BufferedInputStream bis = null;
BufferedOutputStream bos = null;
try {
System.out.println("request.getContentType()...." +
request.getContentType());
is = request.getInputStream();
bis = new BufferedInputStream(is);
bos = new BufferedOutputStream(new FileOutputStream(new
File("d:/naseem.txt")));
int i=0;
while ((i = bis.read())!=-1) {
bos.write(i);
bos.flush();
catch(Exception e){
e.printStackTrace();
finally{
try{
if(bos!=null && is!=null && bis!=null){
bos.close();is.close();bis.close();
}catch(Exception e){e.printStackTrace();}
Above jsp writes the content of browsed file to d:/naseem.txt
Problem which I am facing is besides the actual content, it
also write something else.
Actual file:
quote:
My Text
upload txt file which I got: naseem.txt
quote:
------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2
Content-Disposition: form-data; name="Filename"
test.txt
------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2
Content-Disposition: form-data; name="author=Author";
filename="test.txt"
Content-Type: application/octet-stream
My Text
------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2
Content-Disposition: form-data; name="Upload"
Submit Query
------------cH2ei4GI3ae0KM7cH2GI3ei4ae0cH2--
My question is how do I remove these content-disposition,
content type i.e., extra things from my file. I need only content
to be written in the file.
Regards,
Naseem

Hi Naseem,
You need a multipart request parsing utility. Check commons-fileupload for example.

Similar Messages

  • Is there a way to get to a certain measure without having to scroll the line thing all the way there if our file is hours long?

    Is there a way to get to a certain measure without having to scroll the line thing all the way there if our file is hours long?

    CNWSMT wrote:
    Is there a way to get to a certain measure without having to scroll the line thing all the way there if our file is hours long?
    double click the measures display (the LCD) and type in the measure

  • Pdf on Windows 8;How do I get adobe to be the default app for pdf files.

    I installed pdf reader on my windows 8 laptop, but windows only opens with its "TWINUI". In its "other" option acrobat reader doesn't appear. It also doesn't appear on the windows desktop.
    How do I get adobe to be the default app for pdf files.

    http://winsupersite.com/article/windows8/windows-8-tip-change-file-associations-144102

  • How do I get Muse to remember the last directory when accessing files?

    When I use Muse, I can't get it to remember the last directory or folder I used to access site assets. Every time I go back to access another image or document, explorer has me navigate from the "My Documents" folder to my project folder instead of remembering the last folder I accessed for that Site Project (like most software does).
    How do I set Muse to remember my project's folder within a session instead of having me navigate through the My Documents folder back to the project folder every time I want to access a new asset.
    Thanks.

    Hello,
    This "Adobe Air" bug has been identified and is being currently worked upon for a fix in the upcoming releases: http://forums.adobe.com/message/5612009#5612009#5612009
    Cheers
    Parikshit

  • ?  I get a questionmark  in the middle  of a QT file   what doe this mean

    Hello,
    I have a question.... I Downloaded a file(QT) The other day... it plays for a short time and then stops. it does not get to the end of the file... and then other time when i download it i get the following message.. " the buffer had been detected(then it names the QT program and where it is on my HD) then it goes on to tell me that it has corrupted the internal state of the program and then it tells me that it cannot continue and must be shut down"
    i have uninstalled and re installed same thing... other files work but this one does not.... i have also gone to major sites(yahoo) and there it is.. the big question mark(when they have a movile trailer or something to look at....
    does anyone have any ideas?
    thanks gig
    [email protected]

    The link you provided (above) will help many PC users in regard to this "Question Mark Q" issue and thanks for finding it.
    I only use my PC for a few tasks each week and both Flash and QuickTime seem to not cause any troubles when I browse using IE 7 on it.
    QuickTime 7.1 may have been the first release that acknowledged the Flash security issues and Apple "turned off" Flash media in any default install (local files or web based files).
    The "browser" options for Flash Media have always been set to "off" in any QuickTime install so end users must have "enabled" it via the QT Control Panel. It's found in MIME Settings (version 6) or File Types in version 7.
    An "additional" layer of security is that, in version 7.1.3, Flash media is also disabled by default install of QuickTime (both browser and local files) and PC and Mac users must "enable" Flash media (Control Panel or System Preferences) before Flash formats can be viewed in any QuickTime Player window or in any browser.
    QuickTime 4 introduced Flash media to QuickTime (back when it was owned by Macromedia). Now that Adobe has purchased out Macromedia Flash support in QuickTime may move from its current limits of "version 5, or lower" to more recent releases of Flash.
    Since I regularly use Flash media in many of my QuickTime files I welcome Adobe's purchase and look forward to a better partnership and more features for QuickTime Pro users.
    Oh! I forgot to include an example of Flash in QuickTime:
    http://homepage.mac.com/kkirkster/xmas/index.html
    Done in 2003 but it is Christmas every year this time.

  • Can not get exclusive lock on the shared drive of Azure file storage

    One of my application need exclusive access on the data folder where it writes the data.
    I have setup data folder in Z drive which is shared drive of Azure File system.
    The application is not able to get the exclusive access on the data folder and throws IO exception.
    Is that not possible with shared drive of azure file system

    Hi Subodh,
    You could refer the following link for details on how pessimistic concurrency (Exclusive lock) managed in Azure Storage:
    http://azure.microsoft.com/blog/2014/09/08/managing-concurrency-in-microsoft-azure-storage-2/
    Please be advised that an Exclusive lock on an Azure File Share is not possible using REST Protocol and need to be done using the SMB Protocol.
    You could refer the following link for details on how to manage SMB File locking:
    https://msdn.microsoft.com/en-us/library/azure/dn194265.aspx?f=255&MSPPError=-2147217396
    Hope this helps.
    Regards,
    Malar.

  • HT5312 i have set up and erified my emergency email and still dont get a thing at the bottom of my security questions telling me i can send something to my email to reset my security qestions.

    what should i do? i can no longer geg anything off miad until i do

    Welcome to the Apple Community.
    If don't have a rescue address, you might try contacting Apple through iTunes Store Support

  • Problem with DOCTYPE tag in the index.html for flex file

    When I have the following !DOCTYPE tag in the index.html file I use to load the flex swf file(s) both FireFox and Orical browsers both become horizontally shortened.  When the tag removed everything works fine.  Given that the !DOCTYPE tag is necessary for good html I'd really like to know what's going on.
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    Good info on that site about HTML, unfortunatly it had nothing new for me.  I did double check and everything and I was doing things the way they recomend.
    I'm really bothered that this is happening.  The DOCTYPE tag should be used and it should not have this effect when added to the HTML generated by the Flex Builder.  Additionally the new Flash Builder does have the DOCTYPE tag in its generated HTML and this is very worrisome.

  • Uninstalled, tried to reinstall firefox- get message Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to

    Firefox would not load Yahoo home page properly, checked add ons and plugins-no problem. So unistalled. When reinstalling, went through until the end, then I get:
    Windows cannot access the specified device, path, or file. You may not have the appropriate permissions to access this item.
    I went through the Help section on this page, even to right clicking the file and "run as administrator". It went through and restarted the computer. When I went to look for the program, it wasn't listed in All programs. I searched files and the only thing there was the same message as above.

    Do a clean (re)install and delete the Firefox program folder (C:\Program Files\Mozilla Firefox\).
    Download a fresh Firefox copy and save the file to the desktop.
    *Firefox 13.0.x: http://www.mozilla.org/en-US/firefox/all.html
    Uninstall your current Firefox version, if possible.
    *Do NOT remove personal data when you uninstall your current Firefox version, because all profile folders will be removed and you will also lose your personal data like bookmarks and passwords from profiles of other Firefox versions.
    Remove the Firefox program folder before installing that newly downloaded copy of the Firefox installer.
    *It is important to delete the Firefox program folder to remove all the files and make sure that there are no problems with files that were leftover after uninstalling.
    *http://kb.mozillazine.org/Uninstalling_Firefox
    Your bookmarks and other profile data are stored elsewhere in the Firefox Profile Folder and won't be affected by a reinstall, but make sure that you do not select to remove personal data if you uninstall Firefox.
    *http://kb.mozillazine.org/Profile_folder_-_Firefox
    *http://kb.mozillazine.org/Profile_backup
    *http://kb.mozillazine.org/Standard_diagnostic_-_Firefox#Clean_reinstall

  • I get extra characters with punctuation in my downloads

    I get extra characters at the end of my sentences with my eBook downloads.  How do I get rid of them.

    Hi "g_g_m_mayers"
    I’m sorry but, that’s not an issue…It’s about normal…
    Here for example, is PRS-T2 menu, with all reading books “appearance” selections.  PRS-T2 (Esupport.Sony US)
    About page size:
    If you select from the menu as “font size” the second icon from left, you’ll have the original page layout of the ebook.
    About fonts:
    With fonts all depends on ebook's file.
    If file includes one or more set of fonts, and you select on reader device Font Type “Original”, you’ll have the original fonts on reader and they will be also the same on PC.
    For example:
    If fonts in ebook were, Greek or Cyrillic or calligraphic or special characters, they will be also on reader device Greek or Cyrillic or calligraphic or special and they will be the same even on PC.
    In this case we have the same fonts on PC, on Reader device and on original book.
    But what happens if the ebook’s file does not include set of fonts?
    Reader device will try to type ebook with the built-in characters (Amasis, Frutiger Neue, Helevetica ,Palatino, etc..) and probably they won’t be the same as the original. Reader device, also, doesn’t include special or other language characters and so, probably, you’ll see “strange” characters like “?” “%”, etc.
    On PC now, most of these “special characters” are built-in, so most of times there’s no problem.
    But quite always, PC's ebook viewer software selects different fonts and so we could have:
    Original Book with one type of font, PC ebook with a second type of fonts, Reader device with a third type of fonts.

  • My macbook seems to be going crazy. At certain points (and for hours) I get the oh snap page on chrome, safari doesnt work, macbook wont let me create any files or for example upload music to itunes. I restored my mac so im sure its not a malware problem.

    My macbook seems to be going crazy. At certain points (and for hours) I get the oh snap page on chrome, safari doesnt work, macbook wont let me create any files or for example upload music to itunes. I restored my mac so im sure its not a malware problem. The only thing that solves it is switching off and on , but sometimes I have to do that for 6-7 times before its ok or wait for a few hours. Some help please

    Please read this whole message before doing anything.
    This procedure is a test, not a solution. Don’t be disappointed when you find that nothing has changed after you complete it.
    Step 1
    The purpose of this step is to determine whether the problem is localized to your user account.
    Enable guest logins* and log in as Guest. Don't use the Safari-only “Guest User” login created by “Find My Mac.”
    While logged in as Guest, you won’t have access to any of your personal files or settings. Applications will behave as if you were running them for the first time. Don’t be alarmed by this; it’s normal. If you need any passwords or other personal data in order to complete the test, memorize, print, or write them down before you begin.
    Test while logged in as Guest. Same problem?
    After testing, log out of the guest account and, in your own account, disable it if you wish. Any files you created in the guest account will be deleted automatically when you log out of it.
    *Note: If you’ve activated “Find My Mac” or FileVault, then you can’t enable the Guest account. The “Guest User” login created by “Find My Mac” is not the same. Create a new account in which to test, and delete it, including its home folder, after testing.
    Step 2
    The purpose of this step is to determine whether the problem is caused by third-party system modifications that load automatically at startup or login, by a peripheral device, by a font conflict, or by corruption of the file system or of certain system caches.
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards, if applicable. Start up in safe mode and log in to the account with the problem. You must hold down the shift key twice: once when you turn on the computer, and again when you log in.
    Note: If FileVault is enabled, or if a firmware password is set, or if the startup volume is a Fusion Drive or a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to start up and run than normal, with limited graphics performance, and some things won’t work at all, including sound output and Wi-Fi on certain models. The next normal startup may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin.
    Test while in safe mode. Same problem?
    After testing, restart as usual (not in safe mode) and verify that you still have the problem. Post the results of Steps 1 and 2.

  • I keep getting this error in Dreamweaver when I am trying to upload my website?  Can you tell me what I am doing wrong?  here is the error message: /html - error occurred - Unable to create remote folder /html.  Access denied.  The file may not exist, or

    I keep getting this error in Dreamweaver when I am trying to upload my website?  Can you tell me what I am doing wrong?  here is the error message: /html - error occurred - Unable to create remote folder /html.  Access denied.  The file may not exist, or there could be a permission problem.   Make sure you have proper authorization on the server and the server is properly configured.  File activity incomplete. 1 file(s) or folder(s) were not completed.  Files with errors: 1 /html

    Nobody can tell you anything without knowing exact site and server specs, but I would suspect that naming the folder "html" wasn't the brightest of ideas, since that's usually a default (invisible) folder name existing somewhere on the server and the user not having privileges to overwrite it.
    Mylenium

  • Getting "Warning: The file upload failed.No such file or directory." while trying to upload image using af:inputFile

    Hi,
    I have a <af:inputFile> component which will upload only image file and render  the corresponding image...
    It work with normal application deployed on weblogic server however when i use same taskflow as a part of human task in SOA BPM worklist...
    I get this warning message "Warning: The file upload failed.No such file or directory." for certain files where as it works for certain image files.
    And in BPM whenever i upload PNG file it throws this error.
    Please help.

    For some files like Images with .png extensions it gives following error :
    java.io.IOException: No such file or directory
      at java.io.UnixFileSystem.createFileExclusively(Native Method)
      at java.io.File.checkAndCreate(File.java:1705)
      at java.io.File.createTempFile0(File.java:1726)
      at java.io.File.createTempFile(File.java:1803)
      at org.apache.myfaces.trinidadinternal.config.upload.UploadedFileImpl._createOutputStream(UploadedFileImpl.java:284)
      at org.apache.myfaces.trinidadinternal.config.upload.UploadedFileImpl.loadFile(UploadedFileImpl.java:208)
      at org.apache.myfaces.trinidadinternal.config.upload.CompositeUploadedFileProcessorImpl._processFile(CompositeUploadedFileProcessorImpl.java:344)
      at org.apache.myfaces.trinidadinternal.config.upload.CompositeUploadedFileProcessorImpl.processFile(CompositeUploadedFileProcessorImpl.java:95)
      at org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl._doUploadFile(FileUploadConfiguratorImpl.java:329)
      at org.apache.myfaces.trinidadinternal.config.upload.FileUploadConfiguratorImpl.beginRequest(FileUploadConfiguratorImpl.java:162)
      at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl._startConfiguratorServiceRequest(GlobalConfiguratorImpl.java:610)
      at org.apache.myfaces.trinidadinternal.config.GlobalConfiguratorImpl.beginRequest(GlobalConfiguratorImpl.java:216)
      at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:155)
      at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.bpel.services.workflow.client.worklist.util.WorkflowFilter.doFilter(WorkflowFilter.java:175)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.bpel.services.workflow.client.worklist.util.DisableUrlSessionFilter.doFilter(DisableUrlSessionFilter.java:70)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.adf.library.webapp.LibraryFilter.doFilter(LibraryFilter.java:180)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.security.jps.ee.http.JpsAbsFilter$1.run(JpsAbsFilter.java:119)
      at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:324)
      at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:460)
      at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:103)
      at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:171)
      at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:163)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)
      at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3730)
      at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:3696)
      at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)
      at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)
      at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2273)
      at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2179)
      at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1490)
      at weblogic.work.ExecuteThread.execute(ExecuteThread.java:256)
      at weblogic.work.ExecuteThread.run(ExecuteThread.java:221)

  • To upload the ZIP file and get the filenames available in ZIP file in ABAP

    Hi Experts,
    For my requirement, file from legacy comes as ZIP file with number of files in that.
    Please provide one code sample to upload the ZIP file from local workstation and get the filenames available in ZIP file to check few filename validation checks for the available files in report program.
    Thanks in Advance,
    Regards,
    Basani

    1. Copy the ZIP file into App server
    2. Call function
      call function 'RFC_REMOTE_PIPE'
        destination 'SERVER_EXEC'
        exporting
          command = command  " Unzip command gunzip /path & file
          read = 'X'
        tables
          pipedata = std_lines
    then you can read the files and can validate the file names

  • To run iTunes in 64-bit mooose the "Get Info" command in the File menu, and uncheck the "Open in 32-bit mode" checkbox in the iTunes Info window. but i doesn't have the tick thing plus i redownloaded it a

    To run iTunes in 64-bit mode, select the iTunes application in the Finder, choose the “Get Info” command in the File menu, and uncheck the “Open in 32-bit mode” checkbox in the iTunes Info window. but i doesn't have the tick thing plus i redownloaded it again and same message comes up

    Have you disclosed the "General" brick in the "Info" panel? Click the disclosure triangle to the left of "General":
    What is your iTunes version and MacOS X version?
    -- Léónie

Maybe you are looking for

  • How can I create a new page???

    I do a new actionRouter("jsp"); and it do well but I want to have this page in a new page, no in the same one. Somebody can help me?? thank you

  • Availability Check : Confirmed Date in Sales Order.

    Hello Gurus, I have an issue with the availability check. Scenario : Customer has created an order for quantity 800 on 26th of Feb and accordingly when created the order go confirmed for 17th of March. The specific quanity(batch) of 800 was released

  • How do I prevent the use of electronic signatures?

    I have numerous fillable forms that my office makes available to the general public.  The forms must be printed and signed by hand.  However, we continually receive the documents with digital signatures, and I need to find a way to prevent Reader fro

  • XI/PI: need to create configuration from backend service interface to file

    Hi All, I need to create configuration in which i have to map my backend service interface to file document. For example i have interface CreateOrderInformation_Out which is coming from abckend and i want to store those details in a file on external/

  • Spry Navigation Mac vs Win

    Created Spry menu bar. works fine on Mac/Safari. On Win XP/IE 7 it works but looks bad- the length of each box differs based on text length. Have been told, text within the boxes does not show in IE6. Help.