CCM BAdi During File Upload

Hi All,
We are looking for a BADI during the file upload for Supplier catalog. The requirement is to modify the file ocntents during upload.
We tried implementing BADI /CCM/CTLG_ENRICHMENT, but seems like this BADI is not called during the upload function at all..
Please help us to fix this..
Thanks in Advance
Karthik

Karthik,
The Upload process is launched in a background task, that is why you have to 'insert a infinite loop' as Bertrand said, in order to enter in debug mode through transaction SM50.
PS: Please be careful, and use filters in your BADI implementation, because it is called also in the mapping and publishing processes.
Regards.
Vadim

Similar Messages

  • Error "A web exception has occurred during file upload" when trying to import ESXi image file into Update Manager

    I'm encountering this error and not sure how to fix, I'm quite new to vCenter so please bear with me.
    I'm trying out vCenter 5.1 with Update Manager 5.1 right now.  No license key has been entered and I still have 50 odd days to try it out.
    2 ESXi hosts are being managed by this vCenter, and they're both running ESXi 4.0
    I'm looking to use Update Manager to try to upgrade the ESXi 4.0 hosts to ESXi 5.1
    I downloaded the image file VMware-VIMSetup-all-5.1.0-799735.iso from VMWare website, and is looking to import it using the Update Manager so I can update the ESXi hosts, but I keep on getting the error:
    File name:     VMware-VIMSetup-all-5.1.0-799735.iso
    Failed to transfer data
    Error was: A web exception has occurred during file upload
    I tried importing it by using vSphere client to connect to vCenter server both remotely and locally, with firewall disabled.
    I've read http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1026602
    I've disabled firewall, and there is no anti-virus program on the server.  I've also restarted the machine several times, to no avail, I didn't reinstall update manager because the whole Windows and VCenter installations are clean from scratch.
    I logged into the vSphere Client using Active Directory credentials, and I've made all Domain Admins (which my account is a member of) part of the administrator group on the vCenter server. I can't log in using admin@System-Domain because it tells me I don't have permissions for it, I still haven't really had the chance to figure out why that is and not sure if that makes a difference.
    Also, I'm fairly certain I'm using the right image file, as I've burned some DVD's used that image file to upgrade some other ESXi hosts.  Unless there's a special image file I need to download?
    I'm at lost on what I can do to make it work.  Please advise.
    Thanks.

    The ISO file you mentioned is the one for vCenter Server. What you need is the "VMware-VMvisor-Installer-5.1.0-799733.x86_64.iso" (or VMware-VMvisor-Installer-201210001-838463.x86_64.iso) for the ESXi host.
    André

  • Limited bandwidth during file upload

    Hi All,
    Does it exist a possibility to limit used bandwidth during a file upload from a AIR app?
    For example , is it possible to fix this limit to 10 or 100 kbps?
    Thanks in advance
    Gianni

    Hi,
    any news about this discussion?
    Thanks
    Ennio

  • Threading problem during File Upload with Apache faces upload tag

    First I am going to tell you "My Understanding of how JSF Apache Upload works, Correct me if i am wrong".
    1) Restores View (to show Input box and Browse button to facilitate users to select a file for upload)
    2) Translates Request Parameters to Component Values (Creates equivalent components to update them with request values).
    3) Validates Input(Checks to see whether the User has input the correct file)
    4) Updates Backing Bean or Model to reflect the values.
    5) Renders response to user.
    I am uploading huge files of sizes 400MB and above with the help of JSF apache extensions tag
    <h:form id="uploadForm" enctype="multipart/form-data">
    <x:inputFileUpload style="height:20px;" id="upload" value="#{backingbean.fileContents}" storage="file" size="50" />
    </h:form>
    In the backing bean
    private UploadedFile fileContents;
         public UploadedFile getFileContents() {
              return fileContents;
         public void setFileContents(UploadedFile fileContents) {
              System.out.println("File being uploaded...");
              this.fileContents = fileContents;
    Since, the file size is so huge, I am using temp folder to use for the apache tag instead of memory.
    In web.xml i am using like this
    <filter>
    <filter-name>ExtensionsFilter</filter-name>
    <filter-class>org.apache.myfaces.component.html.util.ExtensionsFilter</filter-class>
    <init-param>
    <param-name>uploadMaxFileSize</param-name>
    <param-value>600m</param-value>
    </init-param>
    <init-param>
    <param-name>uploadThresholdSize</param-name>
    <param-value>10m</param-value>
    </init-param>
         <init-param>
    <param-name>uploadRepositoryPath</param-name>
    <param-value>/uploadfolder/</param-value>
    </init-param>
    </filter>
    <filter-mapping>
    <filter-name>ExtensionsFilter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
    </filter-mapping>
    The upload process is working perfectly fine.
    Now coming to the problem:
    Suppose one user is logging into the application & uploading say 400MB of files.
    Until these files are linked to the model objects as my understanding of step 2, if second user tries to open the application he gets stuck with the loading page.
    The page gets loaded only after the request files are linked to the component values(Step 2 above) and updates the backing bean's values.
    I don't see any error in the logs. User is getting stuck. The user is getting stuck only when uploading the files. The other operations like searching are not blocking any other activities performed by the user.
    Server used: IBM Application Server V6.0. CPU is normal, memory usage is normal.

    Dear friend,
    i am also trying to upload using the common file upload.
    when try to run the file error is coming
    can give some suggestion.
    can i use if concurrent user file upload at a time

  • Error while during file upload in JSF

    Hi
    I do get this error while uploading a file in JSF .
    org.apache.myfaces.webapp.filter.MultipartRequestWrapper.parseRequest(MultipartRequestWrapper.java:134)
         at org.apache.myfaces.webapp.filter.MultipartRequestWrapper.getParameter(MultipartRequestWrapper.java:163)
         at javax.servlet.ServletRequestWrapper.getParameter(ServletRequestWrapper.java:157)
         at com.sun.faces.context.RequestParameterMap.get(ExternalContextImpl.java:673)
         at jsf.PagePhaseListener.afterPhase(PagePhaseListener.java:18)
         at com.sun.faces.lifecycle.LifecycleImpl.phase(LifecycleImpl.java:211)
    Can anybody wat i must do

    thanks....
    but that answer is not solve my question. Actually i want to know.. can we develope a custom tag in JSF for file upload......

  • Facing problem during file upload

    hi
    we r designing a portal where it is required to upload files based on individual users who have logged in.
    For this purpose we r using a file field in one page and http upload tag in another page.
    The file uploads successfuly to the database, but the problem is that we r not able to get the value of pReq.getUser() in the page where the httpfileupload tag exists.
    we noted that request.getParameter() and session.getValue() is also not valid in this page.
    we also tried setting the session value to true in provider.xml. Even this didnt work.
    we noted that this problem comes only when the file field is used. can anyone tell me how to solve this??
    Thanks in advance.
    voyager

    request.getParameter() nor session.getParameter() does not fetch anything. the value is null
    Regards,
    voyager

  • View temporary data in Web layout during file upload in Integrated Planning

    Hi Experts,
    When using File Upload funcationality, in Integrated Planning,
    I have a requirment, How user can view the data in the web layout?
    After data display user can make changes in the data and on click of Save the updated data is saved in cube.
    If any one has come across this requirment can you please help me out how things can be carried out?
    If "how to implement" document is present can you please provide me the link.
    Thanks and Regards,
    Abhi

    Hi Abhi,
    I assume, you are using WAD for this..
    Please do the following: (Please note the the cube has to be in Plan mode while executing WAD)
    1. Create a input enable query (through query designer) on th eaggregate level (the one you are using for IP). You might need to create filers for the aggregate level. these filters can also be used in the query.
    2. In the WAD, pull this query.
    3. Create a button in WAD and check for the planning functionalities readily available that you can use in WAD. One of the planning functionality is SAVE Data. This will save any data which is entered by the user.
    4. In the same button integrate a Refresh Data command after the SAVE data. This will automatically refresh the query and pull the updated/changed data from the cube.
    This should work. Please write back in case of any clarification.
    Regards, Rishi

  • Powershell: There is no file with URL error during file upload.

    I am trying to put together a PowerShell script that I could use to upload files from a local directory, into a Document Library in a Record Center Site. Here is what my script looks like...
    #Open web and library
    $web = Get-SPWeb $webUrl
    $docLibrary = $web.Lists[$docLibraryName]
    $files = ([System.IO.DirectoryInfo] (Get-Item $localFolderPath)).GetFiles()
    Write-Host "Local Directory:" $localFolderPath
    ForEach($file in $files)
    Write-Host "Looping through files"
    Write-Host "Current file:" $file
    ElseIf ($contentType = "MyContentType")
    #Open file
    $fileStream = ([System.IO.FileInfo] (Get-Item $file.FullName)).OpenRead()
    # Gather the file name
    $FileName = $File.Name
    #remove file extension
    $NewName = [IO.Path]::GetFileNameWithoutExtension($FileName)
    #split the file name by the "-" character
    $FileNameArray = $NewName.split("_")
    $check = $FileNameArray.Length
    #Add file
    $folder = $web.getfolder($docLibraryUrlName)
    write-host "Copying file " $file.Name " to " $folder.ServerRelativeUrl "..."
    $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stream]$fileStream, $true)
    $spItem = $spFile.Item
    write-host "Success"
    #populate columns
    $spItem["Application Number"] = $FileNameArray[0].ToString()
    $spItem["Site Number"] = $FileNameArray[1].ToString()
    $spItem.Update()
    $fileStream.Close();
    Each time I run my script, I get this error message 
    Exception calling "Add" with "3" argument(s): "<nativehr>0x80070003</nativehr><nativestack></nativestack>There is no file with URL 'http://myRecordLibrarySite/myRecord Library/12587_B2317.PDF' in this Web."
    At C:\powershellscripts\Upload-FilesIntoSharePoint.ps1:72 char:6
    +                     $spFile = $folder.Files.Add($folder.Url + "/" + $file.Name, [System.IO.Stre ...
    +    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : DirectoryNotFoundException
    I have not been able to nail down why the script is failing. Any ideas why? Thanks for the help.

    I just figured out the issue with adding the file. I went in this direction, and my code has progressed forward.
    $folder = $web.getfolder($docLibrary.rootFolder.URL)

  • CPU HOGGIN DURING FILE UPLOAD

    Hi,
    I was trying to upload files using servlets,
    I am using weblogic 5.1 as server (servlet engine)
    my CPU usage goes to 100% when the file is being transferred...can any one explain why this is hppening and what is the solution for that...
    TIA,
    Sanjy

    I'm assuming the servlet that's handling the file saving was written by you....
    you should be reading the data from the browser in chunks 8k is the largest default size block...
    we'll pretend that this is going to a file and you've got a FileOutputStream already created... I'll call it fos and the inputstream to the browser we'll call that in :)
    byte[] tba=new byte[8192];
    int len=in.read(tba);
    while(len!=-1) {
    fos.write(tba);
    len=in.read(tba);
    if you want more specific help send the chunk of code that deals with recieving the file....

  • Exception During File Upload

    Hi,
    I had deployed the fileupload application in weblogic & i am using apache server to access the URL.some times when i tried to upload a file, i'm getting below exception..
    +"ERROR CommonsMultipartRequestHandler - Failed to parse multipart request+
    +org.apache.commons.fileupload.FileUploadException: Processing of multipart/form-data request failed. EOF after reading only: '0' of: '46939' promised bytes, out of which at least: '0' were already buffered+
    +at org.apache.commons.fileupload.FileUploadBase.parseRequest(FileUploadBase.java:429)+
    +at org.apache.struts.upload.CommonsMultipartRequestHandler.handleRequest(CommonsMultipartRequestHandler.java:233)+
    +at org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1209)+
    +at org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.java:821)+
    +at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:254)+
    +at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)+
    +at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)+
    +at javax.servlet.http.HttpServlet.service(HttpServlet.java:727)+
    +at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)+
    +at weblogic.servlet.internal.StubSecurityHelper$ServletServiceAction.run(StubSecurityHelper.java:227)+
    +"+Can anyone helpme ...?
    Thanks !!!!

    Here is a common tag that is used to upload a file:
    <input type="file">
    Also, have you tried to upload a simple (text) file using your method. Then a file that has simple context but is about the size of the file you have problems with. Then, the file you are trying to upload.
    That will determine if its your upload method, a problem with the size of the file, or something funny about the content of that particular file (perhaps its corrupt).

  • Error during File upload into BI IP

    Hi,
      I have followed the steps outlined in the How-to Guide for loading files into BI-IP (NEtweaver) as posted by Marc. When I execute the same, I get the following error:
    System error in program CL_RSR_FIPT_VAL2SID_PREFETCH and form BEFORE_TRANSFORM-01- (see long text).
       I am not sure why this is happening and also about what should be done! Any ideas are most welcome!
    Thanks and Regards
    Sriram

    Hi Sampath,
    Please ensure you are on SP 15 patch level , else if you are on SP 14  then apply note 1070655 - Termination msg CL_RSPLFR_CONTROLLER =>GET_READ_WRITE_PROVIDS
    b] Apply Correction Instruction 566059 [i.e: in Object - CL_RSPLFR_CONTROLLER GET_READ_WRITE_PROVIDS,
    delete the block: l_r_alvl = cl_rspls_alvl=>factory( i_aggrlevel = p_infoprov ).
    and insert block - l_r_alvl = cl_rspls_alvl=>factory( i_aggrlevel = i_infoprov ).
    Apart from this  ensure at Planning function level create the rows as like in the flat file. Also give correct parameters to the skip header and other functions.
    Hope this helps
    Raja

  • Problem in File Upload - URGENT

    Hi All,
    Advance thanks for your reply
    My Query
    we are not mention the clint-no in my flat file
    During file upload its client no add to itab
    i will mention code also
    parameters: p_file type rlgrap-filename obligatory
    DEFAULT 'c:\temp\pcard.dat'.
    at selection-screen on value-request for p_file.
      call function 'WS_FILENAME_GET'
       exporting
         mask                   = ',.,..'
       importing
         filename               = p_file
    exceptions
       inv_winsys             = 1
       no_batch               = 2
       selection_cancel       = 3
       selection_error        = 4
       others                 = 5.
    call function 'WS_UPLOAD'
           exporting
                filename                = p_file
                filetype                = 'DAT'
           tables
                data_tab                = itAB
           exceptions
                conversion_error        = 1
                file_open_error         = 2
                file_read_error         = 3
                invalid_type            = 4
                no_batch                = 5
                unknown_error           = 6
                invalid_table_width     = 7
                gui_refuse_filetransfer = 8
                customer_error          = 9
                others                  = 10.
    Please send the guide lines or  code for my query
    i look forwar to your reply
    Regards
    Raj

    Check this
    Uploading files from PC(Presentation Server)  
    There are also a number of other function modules which could be used for uploading/downloding files
    between SAP and the presentation server.
    *   Retrieve data file from presentation server(Upload from PC)
    DATA: i_file like rlgrap-filename value '/usr/sap/tmp/file.txt'. 
    DATA: begin of it_datatab occurs 0,
      row(500) type c,
    end of it_datatab.
      CALL FUNCTION 'GUI_UPLOAD'
           EXPORTING
                filename        = i_file
                filetype        = 'ASC'
           TABLES
                data_tab        = it_datatab  "ITBL_IN_RECORD[]
           EXCEPTIONS
                file_open_error = 1
                OTHERS          = 2.
    *& Report  ZUPLOADTAB                                                  *
    *& Example of Uploading tab delimited file                             *
    REPORT  zuploadtab                    .
    PARAMETERS: p_infile  LIKE rlgrap-filename
                            OBLIGATORY DEFAULT  '/usr/sap/'..
    *DATA: ld_file LIKE rlgrap-filename.
    DATA: gd_file type string.
    *Internal tabe to store upload data
    TYPES: BEGIN OF t_record,
        name1 LIKE pa0002-vorna,
        name2 LIKE pa0002-name2,
        age   TYPE i,
        END OF t_record.
    DATA: it_record TYPE STANDARD TABLE OF t_record INITIAL SIZE 0,
          wa_record TYPE t_record.
    *Internal table to upload data into
    DATA: BEGIN OF it_datatab OCCURS 0,
      row(500) TYPE c,
    END OF it_datatab.
    *Text version of data table
    TYPES: BEGIN OF t_uploadtxt,
      name1(10) TYPE c,
      name2(15) TYPE c,
      age(5)  TYPE c,
    END OF t_uploadtxt.
    DATA: wa_uploadtxt TYPE t_uploadtxt.
    *String value to data in initially.
    DATA: wa_string(255) TYPE c.
    CONSTANTS: con_tab TYPE x VALUE '09'.
    *If you have Unicode check active in program attributes then you will
    *need to declare constants as follows:
    *class cl_abap_char_utilities definition load.
    *constants:
    *    con_tab  type c value cl_abap_char_utilities=>HORIZONTAL_TAB.
    *AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_INFILE.
    AT SELECTION-SCREEN ON VALUE-REQUEST FOR P_infile.
      CALL FUNCTION <b>'WS_FILENAME_GET'</b>
           EXPORTING
                def_filename     = p_infile
                mask             = ',*.txt.'
                mode             = 'O'
                title            = 'Upload File'(078)
           IMPORTING
                filename         = p_infile
           EXCEPTIONS
                inv_winsys       = 1
                no_batch         = 2
                selection_cancel = 3
                selection_error  = 4
                OTHERS           = 5.
    *START-OF-SELECTION
    START-OF-SELECTION.
      gd_file = p_infile.
      CALL FUNCTION <b>'GUI_UPLOAD'</b>
        EXPORTING
          filename                = gd_file
          has_field_separator     = 'X'  "file is TAB delimited
        TABLES
          data_tab                = it_record
        EXCEPTIONS
          file_open_error         = 1
          file_read_error         = 2
          no_batch                = 3
          gui_refuse_filetransfer = 4
          invalid_type            = 5
          no_authority            = 6
          unknown_error           = 7
          bad_data_format         = 8
          header_not_allowed      = 9
          separator_not_allowed   = 10
          header_too_long         = 11
          unknown_dp_error        = 12
          access_denied           = 13
          dp_out_of_memory        = 14
          disk_full               = 15
          dp_timeout              = 16
          OTHERS                  = 17.
        IF sy-subrc NE 0.
          write: 'Error ', sy-subrc, 'returned from GUI_UPLOAD FM'.
          skip.
        endif.
    * Alternative method, where by you split fields at each TAB after you
    * have returned the data. No point unless you dont have access to
    * GUI_UPLOAD but just included for information 
    *  CALL FUNCTION 'GUI_UPLOAD'
    *       EXPORTING
    *            filename        = gd_file
    *            filetype        = 'ASC'
    *       TABLES
    *            data_tab        = it_datatab  "ITBL_IN_RECORD[]
    *       EXCEPTIONS
    *            file_open_error = 1
    *            OTHERS          = 2.
    *  IF sy-subrc NE 0.
    *  ELSE.
    *    LOOP AT it_datatab.
    *      CLEAR: wa_string, wa_uploadtxt.
    *      wa_string = it_datatab.
    *      SPLIT wa_string AT con_tab INTO wa_uploadtxt-name1
    *                                      wa_uploadtxt-name2
    *                                      wa_uploadtxt-age.
    *      MOVE-CORRESPONDING wa_uploadtxt TO wa_record.
    *      APPEND wa_record TO it_record.
    *    ENDLOOP.
    *  ENDIF.
    *END-OF-SELECTION
    END-OF-SELECTION.
    *!! Text data is now contained within the internal table IT_RECORD
    * Display report data for illustration purposes
    LOOP AT it_record INTO wa_record.
      WRITE:/     sy-vline,
             (10) wa_record-name1, sy-vline,
             (10) wa_record-name2, sy-vline,
             (10) wa_record-age, sy-vline.
    ENDLOOP.
    http://www.sapdevelopment.co.uk/file/file_updown.htm
    Hope this helps.
    Kindly reward and close the thread.

  • Rename file extension during a file upload ??

    I need to rename the extension of a file at some point during the file upload. I am not sure where to do this at.
    The file needs to be renamed before it is written to the directory.
    Basically, the file will come in with a .txt or .doc type. Based on a users profile, I will change the type to a non-relavent number such as 1111.
    Here is my upload servlet. Can you tell me where to change the type so it will write the file with the new extension?
    Thanks.
    public class FileExport {
    //restrict upload files to 1 Meg
    private static final int DEFAULT_MAX_POST_SIZE = 1024 * 1024;
    private static final String NO_FILE = "unknown";
    private HttpServletRequest req;
    private File dir;
    private int maxSize;
    private Hashtable parameters = new Hashtable(); // name - Vector of values
    private Hashtable files = new Hashtable(); // name - UploadedFile
    public FileExport(HttpServletRequest request,
    String saveDirectory) throws IOException {
    this(request, saveDirectory, DEFAULT_MAX_POST_SIZE);
    // request the servlet request
    // saveDirectory = directory in which to save any uploaded files
    // maxPostSize = maximum size of the POST content
    public FileExport(HttpServletRequest request,
    String saveDirectory,
    int maxPostSize) throws IOException {
    // check values
    if (request == null)
    throw new IllegalArgumentException("request cannot be null");
    if (saveDirectory == null)
    throw new IllegalArgumentException("saveDirectory cannot be null");
    if (maxPostSize <= 0) {
    throw new IllegalArgumentException("maxPostSize must be positive");
    // Save the request, dir, and max size
    req = request;
    dir = new File(saveDirectory);
    maxSize = maxPostSize;
    // Check saveDirectory is truly a directory
    if (!dir.isDirectory())
    throw new IllegalArgumentException("Not a directory: " + saveDirectory);
    // Check saveDirectory is writable
    if (!dir.canWrite())
    throw new IllegalArgumentException("Not writable: " + saveDirectory);
    // Now parse the request saving data to "parameters" and "files";
    // write the file contents to the saveDirectory
    readRequest();
    public FileExport(ServletRequest request,
    String saveDirectory) throws IOException {
    this((HttpServletRequest)request, saveDirectory);
    public FileExport(ServletRequest request,
    String saveDirectory,
    int maxPostSize) throws IOException {
    this((HttpServletRequest)request, saveDirectory, maxPostSize);
    // Returns the names of all the parameters as an Enumeration of
    // Strings. It returns an empty Enumeration if there are no parameters.
    public Enumeration getParameterNames() {
    return parameters.keys();
    // Returns the names of all the uploaded files as an Enumeration of
    // Strings. It returns an empty Enumeration if there are no uploaded
    // files. Each file name is the name specified by the form, not by
    // the user.
    public Enumeration getFileNames() {
    return files.keys();
    // Returns the value of the named parameter as a String, or null if
    // the parameter was not sent or was sent without a value.
    public String getParameter(String name) {
    try {
    Vector values = (Vector)parameters.get(name);
    if (values == null || values.size() == 0) {
    return null;
    String value = (String)values.elementAt(values.size() - 1);
    return value;
    catch (Exception e) {
    return null;
    // Returns the values of the named parameter as a String array, or null if
    // the parameter was not sent.
    public String[] getParameterValues(String name) {
    try {
    Vector values = (Vector)parameters.get(name);
    if (values == null || values.size() == 0) {
    return null;
    String[] valuesArray = new String[values.size()];
    values.copyInto(valuesArray);
    return valuesArray;
    catch (Exception e) {
    return null;
    // Returns the filesystem name of the specified file, or null if the
    // file was not included in the upload. A filesystem name is the name
    // specified by the user. It is also the name under which the file is
    // actually saved.
    public String getFilesystemName(String name) {
    try {
    UploadedFile file = (UploadedFile)files.get(name);
    return file.getFilesystemName(); // may be null
    catch (Exception e) {
    return null;
    // Returns the content type of the specified file (as supplied by the
    //client browser), or null if the file was not included in the upload.
    public String getContentType(String name) {
    try {
    UploadedFile file = (UploadedFile)files.get(name);
    return file.getContentType(); // may be null
    catch (Exception e) {
    return null;
    // Returns a File object for the specified file saved on the server's
    // filesystem, or null if the file was not included in the upload.
    public File getFile(String name) {
    try {
    UploadedFile file = (UploadedFile)files.get(name);
    return file.getFile(); // may be null
    catch (Exception e) {
    return null;
    // method that actually parses the request.
    protected void readRequest() throws IOException {
    // Check the content length to prevent denial of service attacks
    int length = req.getContentLength();
    if (length > maxSize) {
    throw new IOException("Posted content length of " + length +
    " exceeds limit of " + maxSize);
    // Check the content type to make sure it's "multipart/form-data"
    // Access header two ways to work around WebSphere oddities
    String type = null;
    String type1 = req.getHeader("Content-Type");
    String type2 = req.getContentType();
    // If one value is null, choose the other value
    if (type1 == null && type2 != null) {
    type = type2;
    else if (type2 == null && type1 != null) {
    type = type1;
    // If neither value is null, choose the longer value
    else if (type1 != null && type2 != null) {
    type = (type1.length() > type2.length() ? type1 : type2);
    if (type == null ||
    !type.toLowerCase().startsWith("multipart/form-data")) {
    throw new IOException("Posted content type isn't multipart/form-data");
    // Get the boundary string; it's included in the content type.
    // Should look something like "------------------------12012133613061"
    String boundary = extractBoundary(type);
    if (boundary == null) {
    throw new IOException("Separation boundary was not specified");
    // Construct the special input stream we'll read from
    MultipartInputStreamHandler in =
    new MultipartInputStreamHandler(req.getInputStream(), length);
    // Read the first line, should be the first boundary
    String line = in.readLine();
    if (line == null) {
    throw new IOException("Corrupt form data: premature ending");
    // Verify that the line is the boundary
    if (!line.startsWith(boundary)) {
    throw new IOException("Corrupt form data: no leading boundary");
    // Now that we're just beyond the first boundary, loop over each part
    boolean done = false;
    while (!done) {
    done = readNextPart(in, boundary);
    // A utility method that reads an individual part. Dispatches to
    // readParameter() and readAndSaveFile() to do the actual work. A
    // subclass can override this method for a better optimized or
    // differently behaved implementation.
    protected boolean readNextPart(MultipartInputStreamHandler in,
    String boundary) throws IOException {
    // Read the first line, should look like this:
    // content-disposition: form-data; name="field1"; filename="file1.txt"
    String line = in.readLine();
    if (line == null) {
    // No parts left, we're done
    return true;
    else if (line.length() == 0) {
    // IE4 on Mac sends an empty line at the end; treat that as the end.
    // Thanks to Daniel Lemire and Henri Tourigny for this fix.
    return true;
    // Parse the content-disposition line
    String[] dispInfo = extractDispositionInfo(line);
    String disposition = dispInfo[0];
    String name = dispInfo[1];
    String filename = dispInfo[2];
    // Now onto the next line. This will either be empty
    // or contain a Content-Type and then an empty line.
    line = in.readLine();
    if (line == null) {
    // No parts left, we're done
    return true;
    // Get the content type, or null if none specified
    String contentType = extractContentType(line);
    if (contentType != null) {
    // Eat the empty line
    line = in.readLine();
    if (line == null || line.length() > 0) {  // line should be empty
    throw new
    IOException("Malformed line after content type: " + line);
    else {
    // Assume a default content type
    contentType = "application/octet-stream";
    // Now, finally, we read the content (end after reading the boundary)
    if (filename == null) {
    // This is a parameter, add it to the vector of values
    String value = readParameter(in, boundary);
    if (value.equals("")) {
    value = null; // treat empty strings like nulls
    Vector existingValues = (Vector)parameters.get(name);
    if (existingValues == null) {
    existingValues = new Vector();
    parameters.put(name, existingValues);
    existingValues.addElement(value);
    else {
    // This is a file
    readAndSaveFile(in, boundary, filename, contentType);
    if (filename.equals(NO_FILE)) {
    files.put(name, new UploadedFile(null, null, null));
    else {
    files.put(name,
    new UploadedFile(dir.toString(), filename, contentType));
    return false; // there's more to read
    // A utility method that reads a single part of the multipart request
    // that represents a parameter. A subclass can override this method
    // for a better optimized or differently behaved implementation.
    protected String readParameter(MultipartInputStreamHandler in,
    String boundary) throws IOException {
    StringBuffer sbuf = new StringBuffer();
    String line;
    while ((line = in.readLine()) != null) {
    if (line.startsWith(boundary)) break;
    sbuf.append(line + "\r\n"); // add the \r\n in case there are many lines
    if (sbuf.length() == 0) {
    return null; // nothing read
    sbuf.setLength(sbuf.length() - 2); // cut off the last line's \r\n
    return sbuf.toString(); // no URL decoding needed
    // A utility method that reads a single part of the multipart request
    // that represents a file, and saves the file to the given directory.
    // A subclass can override this method for a better optimized or
    // differently behaved implementation.
    protected void readAndSaveFile(MultipartInputStreamHandler in,
    String boundary,
    String filename,
    String contentType) throws IOException {
    OutputStream out = null;
    // A filename of NO_FILE means no file was sent, so just read to the
    // next boundary and ignore the empty contents
    if (filename.equals(NO_FILE)) {
    out = new ByteArrayOutputStream(); // write to nowhere
    // A MacBinary file goes through a decoder
    else if (contentType.equals("application/x-macbinary")){
    File f = new File(dir + File.separator + filename);
    out = new MacBinaryDecoderOutputStream(
    new BufferedOutputStream(
    new FileOutputStream(f), 8 * 1024));
    // A real file's contents are written to disk
    else {
    File f = new File(dir + File.separator + filename);
    out = new BufferedOutputStream(new FileOutputStream(f), 8 * 1024);
    byte[] bbuf = new byte[100 * 1024]; // 100K
    int result;
    String line;
    // ServletInputStream.readLine()
    // adds a \r\n to the end of the last line.
    // Since we want a byte-for-byte transfer, we have to cut those chars.
    boolean rnflag = false;
    while ((result = in.readLine(bbuf, 0, bbuf.length)) != -1) {
    // Check for boundary
    if (result > 2 && bbuf[0] == '-' && bbuf[1] == '-') { // quick pre-check
    line = new String(bbuf, 0, result, "ISO-8859-1");
    if (line.startsWith(boundary)) break;
    // Are we supposed to write \r\n for the last iteration?
    if (rnflag) {
    out.write('\r'); out.write('\n');
    rnflag = false;
    // Write the buffer, postpone any ending \r\n
    if (result >= 2 &&
    bbuf[result - 2] == '\r' &&
    bbuf[result - 1] == '\n') {
    out.write(bbuf, 0, result - 2); // skip the last 2 chars
    rnflag = true; // make a note to write them on the next iteration
    else {
    out.write(bbuf, 0, result);
    out.flush();
    out.close();
    // Extracts and returns the boundary token from a line.
    private String extractBoundary(String line) {
    // Use lastIndexOf() because IE 4.01 on Win98 has been known to send the
    // "boundary=" string multiple times. Thanks to David Wall for this fix.
    int index = line.lastIndexOf("boundary=");
    if (index == -1) {
    return null;
    String boundary = line.substring(index + 9); // 9 for "boundary="
    // The real boundary is always preceeded by an extra "--"
    boundary = "--" + boundary;
    return boundary;
    // Extracts and returns disposition info from a line, as a String array
    // with elements: disposition, name, filename. Throws an IOException
    // if the line is malformatted.
    private String[] extractDispositionInfo(String line) throws IOException {
    // Return the line's data as an array: disposition, name, filename
    String[] retval = new String[3];
    // Convert the line to a lowercase string without the ending \r\n
    // Keep the original line for error messages and for variable names.
    String origline = line;
    line = origline.toLowerCase();
    // Get the content disposition, should be "form-data"
    int start = line.indexOf("content-disposition: ");
    int end = line.indexOf(";");
    if (start == -1 || end == -1) {
    throw new IOException("Content disposition corrupt: " + origline);
    String disposition = line.substring(start + 21, end);
    if (!disposition.equals("form-data")) {
    throw new IOException("Invalid content disposition: " + disposition);
    // Get the field name
    start = line.indexOf("name=\"", end); // start at last semicolon
    end = line.indexOf("\"", start + 7); // skip name=\"
    if (start == -1 || end == -1) {
    throw new IOException("Content disposition corrupt: " + origline);
    String name = origline.substring(start + 6, end);
    // Get the filename, if given
    String filename = null;
    start = line.indexOf("filename=\"", end + 2); // start after name
    end = line.indexOf("\"", start + 10); // skip filename=\"
    if (start != -1 && end != -1) {                // note the !=
    filename = origline.substring(start + 10, end);
    // The filename may contain a full path. Cut to just the filename.
    int slash =
    Math.max(filename.lastIndexOf('/'), filename.lastIndexOf('\\'));
    if (slash > -1) {
    filename = filename.substring(slash + 1); // past last slash
    if (filename.equals("")) filename = NO_FILE; // sanity check
    // Return a String array: disposition, name, filename
    retval[0] = disposition;
    retval[1] = name;
    retval[2] = filename;
    return retval;
    // Extracts and returns the content type from a line, or null if the
    // line was empty. Throws an IOException if the line is malformatted.
    private String extractContentType(String line) throws IOException {
    String contentType = null;
    // Convert the line to a lowercase string
    String origline = line;
    line = origline.toLowerCase();
    // Get the content type, if any
    if (line.startsWith("content-type")) {
    int start = line.indexOf(" ");
    if (start == -1) {
    throw new IOException("Content type corrupt: " + origline);
    contentType = line.substring(start + 1);
    else if (line.length() != 0) {  // no content type, so should be empty
    throw new IOException("Malformed line after disposition: " + origline);
    return contentType;
    // A class to hold information about an uploaded file.
    class UploadedFile {
    private String dir;
    private String filename;
    private String type;
    UploadedFile(String dir, String filename, String type) {
    this.dir = dir;
    this.filename = filename;
    this.type = type;
    public String getContentType() {
    return type;
    public String getFilesystemName() {
    return filename;
    public File getFile() {
    if (dir == null || filename == null) {
    return null;
    else {
    return new File(dir + File.separator + filename);
    // A class to aid in reading multipart/form-data from a ServletInputStream.
    // It keeps track of how many bytes have been read and detects when the
    // Content-Length limit has been reached.
    class MultipartInputStreamHandler {
    ServletInputStream in;
    int totalExpected;
    int totalRead = 0;
    byte[] buf = new byte[8 * 1024];
    public MultipartInputStreamHandler(ServletInputStream in,
    int totalExpected) {
    this.in = in;
    this.totalExpected = totalExpected;
    // Reads the next line of input. Returns null to indicate the end
    // of stream.
    public String readLine() throws IOException {
    StringBuffer sbuf = new StringBuffer();
    int result;
    String line;
    do {
    result = this.readLine(buf, 0, buf.length); // this.readLine() does +=
    if (result != -1) {
    sbuf.append(new String(buf, 0, result, "ISO-8859-1"));
    } while (result == buf.length); // loop only if the buffer was filled
    if (sbuf.length() == 0) {
    return null; // nothing read, must be at the end of stream
    sbuf.setLength(sbuf.length() - 2); // cut off the trailing \r\n
    return sbuf.toString();
    // A pass-through to ServletInputStream.readLine() that keeps track
    // of how many bytes have been read and stops reading when the
    // Content-Length limit has been reached.
    public int readLine(byte b[], int off, int len) throws IOException {
    if (totalRead >= totalExpected) {
    return -1;
    else {
    if (len > (totalExpected - totalRead)) {
    len = totalExpected - totalRead; // keep from reading off end
    int result = in.readLine(b, off, len);
    if (result > 0) {
    totalRead += result;
    return result;
    // Class to filters MacBinary files to normal files on the fly
    // Optimized for speed more than readability
    class MacBinaryDecoderOutputStream extends FilterOutputStream {
    int bytesFiltered = 0;
    int dataForkLength = 0;
    public MacBinaryDecoderOutputStream(OutputStream out) {
    super(out);
    public void write(int b) throws IOException {
    // Bytes 83 through 86 are a long representing the data fork length
    // Check <= 86 first to short circuit early in the common case
    if (bytesFiltered <= 86 && bytesFiltered >= 83) {
    int leftShift = (86 - bytesFiltered) * 8;
    dataForkLength = dataForkLength | (b & 0xff) << leftShift;
    // Bytes 128 up to (128 + dataForkLength - 1) are the data fork
    else if (bytesFiltered < (128 + dataForkLength) && bytesFiltered >= 128) {
    out.write(b);
    bytesFiltered++;
    public void write(byte b[]) throws IOException {
    write(b, 0, b.length);
    public void write(byte b[], int off, int len) throws IOException {
    // If the write is for content past the end of the data fork, ignore
    if (bytesFiltered >= (128 + dataForkLength)) {
    bytesFiltered += len;
    // If the write is entirely within the data fork, write it directly
    else if (bytesFiltered >= 128 &&
    (bytesFiltered + len) <= (128 + dataForkLength)) {
    out.write(b, off, len);
    bytesFiltered += len;
    // Otherwise, do the write a byte at a time to get the logic above
    else {
    for (int i = 0 ; i < len ; i++) {
    write(b[off + i]);

    I am also need to rename a file and extension while uploadinf the file to the server. The oreilly example seems only save as the same file name and ext. I wonder if you have the ability chANGE OIT OR NOT. pLEASE LET ME KNOW
    thanks
    kansen

  • Has anyone been able to upload an ibooks file with audio only files (m4a) in it? I keep getting the following error message during the upload in iTunes Producer: ERROR ITMS-9000: "Files of type audio/x-m4a are not allowed outside of widgets.

    Has anyone been able to upload an ibooks file with audio only files (m4a) in it? I keep getting the following error message during the upload in iTunes Producer: ERROR ITMS-9000: "Files of type audio/x-m4a are not allowed outside of widgets. then it names the file as an m4p file. Everything works beautifully on the iPad through Preview, and validates through iTunes Producer up until the attempted upload. If you've been able to accomplish this, please let me know how you prepared your audio files. Many thanks.

    Hello Fellow iBook Authors!
    Today I received the same error that you all have been discussing.  I tried selecting the DRM
    and this did not work for me, though I'm glad it did for some.  Here's what I did as a work-around. . .
    Since iBooks Author did not have a problem with Videos, I simply used one of my video programs, ScreenFlow to turn the audio into a video file m4v.  I added an image and extended the length or timing of the image to span the length of the audio file.  Then exported as an .mov.  I then opened QuickTime and opened the file and exported the file to iTunes. 
    You can use iMovie, Camtasia or any other progam that will allow you to export the audio as a movie file.  Does this make sense?  I hope this helps, at least in the short-term.
    Michael Williams

  • All my ipod files were erased during an upload

    I have never had trouble uploading my ipod until this morning when I was putting several new albums on it, it said they were done uploading so when I clicked on my ipod in iTunes to check if all of them were there, and it hadn't actually done anything. During an upload it said that an artwork file was corrupted. I looked at my iPod and the 'do not disconnect' message was frozen, so I unplugged it and restarted it. When I turned it back on and went to my music, everything was gone instead of the files I just tried to upload. I was using my ipod as a hard drive so none of my files were backed up. I always have had it manually upload songs onto it instead of it automatically copying my library on this computer. I know that my other files are pretty much lost but how did this happen? If it was a specific file how do I locate it and if I don't delete it, will it happen again? I'm so mad right now, I had a 9 hour flight tommorow and I lost over 2000 songs.

    Hello Michael,
    See this older thread from another forum member Zevoneer discussing the various methods for transferring content from your iPod to your computer.
    https://discussions.apple.com/thread/2452022?start=0&tstart=0
    B-rock

Maybe you are looking for

  • Bunch of brand new mail problems

    Mail has worked great from day 1 (6/29) until two days ago. I have been getting a fairly constant progress indicator at the bottom of the screen "Sending x of 24" while the iPhone apparently is sending something. When it completes, it signals with th

  • Error in loading Master Data

    Hi All, i have an error in loading master and i want to know please how can i individuate the data that need to be corrected, i have loaded data in psa and when i click on simulate/cancel update i find an error in data package 19 and data record 6701

  • Newbie trying to sort 2D string array

    Dear all, After read some book chapters, web sites including this, I still don't get the point. If I have a file like, 1 aaa 213 0.9 3 cbb 514 0.1 2 abc 219 1.3 9 bbc 417 10.4 8 dee 887 2.1 9 bba 111 7.1 and I load into memory as a String[][] here co

  • Space designer pop and clicks

    Hi guys, I have two work stations in my studio. on my secondary wrokstation, I run a 1.8 dual powermac with the latest Logic 7.2. Ever since I upgraded to OSX 10.4.10 I'm having problems with the space designer. it starts creating clicks, pops and di

  • Don't force selected clip to the top

    Hello, If you do this: Record a punch in on an existing clip. Click on the original clip (maybe to select another area to punch in) The original clip now hides the punch in. This makes extra work because you have to come up with a work-around such as