Retaining the fileName inside the zipped files

Hi Experts,
I am working on a file to file scenario, in which the files have to be picked up the files in pair(pdf) and zip them  and post in the particular folder.
I have used PayloadZipBean for zipping the files, but not able to get the original file names inside the zip, but i am getting one Mail and one additional file.
This thread seems to be similar to my problem:
Re: ZIP FileName (Additional Files)
Please suggest.
Thanks,
Sushama

Hi,
I have done developed an adapter module for retaining the file name, before PauloadZip Bean, in receiver file adapter:
package sample;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext;
import com.sap.aii.af.mp.module.*;
import com.sap.aii.af.ra.ms.api.*;
@ejbHome <{com.sap.aii.af.mp.module.ModuleHome}>
@ejbLocal <{com.sap.aii.af.mp.module.ModuleLocal}>
@ejbLocalHome <{com.sap.aii.af.mp.module.ModuleLocalHome}>
@ejbRemote <{com.sap.aii.af.mp.module.ModuleRemote}>
@stateless
public class SetAttachmentName implements SessionBean, Module{
     private SessionContext myContext;
     public void ejbRemove() {
     public void ejbActivate() {
     public void ejbPassivate() {
     public void setSessionContext(SessionContext context) {
          myContext = context;
     public void ejbCreate() throws CreateException {
public ModuleData process(ModuleContext moduleContext, ModuleData inputModuleData)
                      throws ModuleException{
     try {
        Message msg = (Message) inputModuleData.getPrincipalData();
        Payload payload = msg.getDocument();
        String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File",
                                                 "FileName");
        if(fileName == null) fileName="default.txt";
        payload.setContentType("text/plain;charset = \"UTF-8\";"
                               + "name=\"" + fileName + "\"");
        inputModuleData.setPrincipalData(msg);
    } catch (Exception e) {
        throw new ModuleException(e);
    return inputModuleData;
But, I am getting corrupted files .
Please advise.
Thanks,
sushama
Edited by: sushama pandey on Sep 28, 2011 4:52 AM

Similar Messages

  • 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

  • PayloadZipBean - variable filename inside the archive

    Hi,
    I'm using the Adapter-Specific Message Properties in a sender fileadapter to determine the incoming filename, which has variable components (i.e. date and time). After changing the prefix and suffix in a Message-Mapping the new name is applied in a receiver fileadapter. The new name is now part of the payload in the tag <Filename>. The receiver fileadapter contains the PayloadZipBean to compress the output file, everything works fine.
    Now I want the file inside my compressed archive always to have the same name as my archive has. In Stefan Grube's blog about the PayloadZipBean I only found the possibility to choose a fix name by using the MessageTransformBean (name="file.txt").
    Example:
    1. variable input filename:                       IN_RNK_20080227_1006.txt
    2. filename after Message-Mapping:        OUT_RNK_20080227_1006.gz
    3. archive filename after receiver adapter: OUT_RNK_20080227_1006.gz
        filename inside the archive:                 MainDocument (this is the default (payload-name))
    I would like to name the file inside the archive OUT_RNK_20080227_1006, too.
    Question 1: Is there any possibility to read out the mapped <Filename>-tag from the payload to use it for the element inside my archive (File Name Scheme and Variable Substitution don't work when using Adapter-Specific Message Properties).
    Question 2: Is there a way to modify the name of the payload so that I can change "MainDocument" to "OUT_RNK_20080227_1006"?
    I'm on XI 3.0 - SP19.
    Many thanks,
    Ralph

    >
    Stefan Grube wrote:
    > In this thread there is a module for reading the content type and setting the dynamic configuration:
    > sender mail adapter - attachment name
    > It should be not be so difficult to derive the reverse way
    Thanks for this info Stefan.
    [Stefan Grube's webinar on custom adapter module development|https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/64a6bdab-0c01-0010-079a-b3707717cecd?prtmode=navigate]
    The code of the EJB module we had to write to get the filename from the Dynamic Configuration (ASMA) and then set the content type of the message is given below.
    * Created on Apr 23, 2008
    package zfilezipper;
    * @author Krishneel Goundar
    import javax.ejb.CreateException;
    import javax.ejb.SessionBean;
    import javax.ejb.SessionContext;
    import com.sap.aii.af.mp.module.*;
    import com.sap.aii.af.ra.ms.api.*;
    * @ejbHome<{com.sap.aii.af.mp.module.ModuleHome}>
    * @ejbLocal<{com.sap.aii.af.mp.module.ModuleLocal}>
    * @ejbLocalHome<{com.sap.aii.af.mp.module.ModuleLocalHome}>
    * @ejbRemote<{com.sap.aii.af.mp.module.ModuleRemote}>
    * @stateless
    public class SetContentTypeEJB implements SessionBean, Module{
         private SessionContext myContext;
         public void ejbRemove() {}
         public void ejbActivate() {}
         public void ejbPassivate() {}
         public void setSessionContext(SessionContext context) {
         myContext = context;
         public void ejbCreate() throws CreateException{}
         public ModuleData process(ModuleContext moduleContext,ModuleData inputModuleData) throws ModuleException{
              try {               
                   Message msg = (Message) inputModuleData.getPrincipalData();     //Used to read dynamic configuration data
                   TextPayload payload = msg.getDocument();     //Used to set 'contentType' value
                   //The name of the file to be zipped is read from the dynamic configuration.
                   String fileName = msg.getMessageProperty("http://sap.com/xi/XI/System/File", "FileName");
                   if(fileName == null)     //If no file name can be determined we set 'contentType' to "defaultbeanile.txt"
                        payload.setContentType("text/plain;charset = \"UTF-8\";filename=\"defaultbeanfile.txt\"");     
                   else     //If a file name can be found we set 'contentType' to the name of the file.
                        payload.setContentType("text/plain;charset = \"UTF-8\";filename=\"" + fileName + "\"");     
                   //After setting the value of 'contentType' we need to update the ModuleData object (inputModuleData).
                   inputModuleData.setPrincipalData(msg);
              } catch (Exception e) {
                   ModuleException me = new ModuleException(e);
                   throw me;
              return inputModuleData;          //Return the updated ModuleData object.
    Edited by: Charu Kulkarni on Apr 28, 2008 1:41 AM

  • Retaining the FileName in the Receiver FTP adapter

    Hi experts,
    I have a situation here, were i need to retain the FileName in the message header in the receiver FTP adapter.
    I have tried using variable subtitution but seems the FileName is not supported in variable substitution.
    Please help
    Thanks

    Hello,
    if you need file name to be retained in the receiver adapter from the sender side. then u can do that by dynamic configuration using adapter specific message attributes, check this blog for details-
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    if you dont have a mapping in your interface to use dynamic configuration, then you can do it via adapter module also- have a look here, /people/sap.user72/blog/2005/07/15/copy-a-file-with-same-filename-using-xi
    regards,
    francis

  • Setting the name of streamed zip file

    Hi,
    I have a servlet which creates a zip file with documents retrieved from a database. To create the zip file I am using the ZipOutputStream class and adding the documents one at a time to this object. This is all working fine.
    The problem I have is pretty simple, in that I can't seem to find a way in which to set the name of the zip file. This must be possible! At the moment it appears to be setting the name of the zip file to the name of the class that created it. In this case my class is called DocumentPacker and what comes back from the servlet is a zip file called DocumentPacker.zip. This wouldn't be so bad, but if you're creating the zip file for a user that does not have cookies enabled, it appends the session id to the end of the zip file name which i don't want.
    I am creating my ZipOutputStream like this:
    ZipOutputStream out = new ZipOutputStream(new BufferedOutputStream(response.getOutputStream()));
    and then adding the documents one at a time using a BufferedInputStream.).
    Any help on how to set the name would be much appreciated
    Thanks
    Claire

    Your servlet must set some headers on the HTTP response (Content-Type as "application/zip", Content-Disposition as "attachment; filename=yourfilename.zip")
    Read the RFC1806 document.
    Content-Type: application/zip
    Content-Disposition: attachment; filename=genome.jpeg

  • Panagon and MGETDOC Application:open a doc, the doc goes to .zip file instead of going to the doc directly

    Application: FileNet content SG (Panagon) and MGETDOC(Web application)
    Issue: when open a doc, the doc goes to .zip file instead of going to the doc directly. Only this issue happens for .xlsx,docs and pptx document.
    Note: On all client machine, we are using office 2007 and IE8 browser
    Cause: On 16<sup>th</sup> July 2013, . Net framework 4.5 is install on all our GI-D desktop machines. There after the issue is started .
    Application Background: Applications built on .net framework 1.1 and it can support up to 4.0 version on client machine to view the documents through panagon and MGETDOC application. Panagon (Filenet content services) is
    not supported in .net framework 4.5 and above.
    Work around: After I had troubleshooting and tested with one of our  system which has .net framework 4.5, IE8 does not support with HTML5 and tested with IE9 and Chrome, documents were able to open successfully.
    I had removed .Net framework 4.5 uninstalled and able to open the documents w/o any issue. And also we had give the work around as if the doc goes to zip file, they open the doc by removing the . zip extension and they can save it as .xlsx or docx file and
    they can able to open file.
    Please let us know if you there is a fix to export the files through framework 4.5 and do contact us if you need further details, we shall discuss on the same. Thank you for your support. Request you to email @
    [email protected]/[email protected]
    Candida

    Presumably you're using Safari?
    You can change that in Safari Preferences (at least in 5.0.3, might be different in 5.1.x)
    The checkbox at the bottom will do that for you. However! I strongly advise against permitting that; there have been, and no doubt will be again, malware that uses that to bypass authentication.
    Just select Desktop as the default download location so you don't have to dig for the files.

  • How to extract the audio of a zip file? if it helps I'm trying to add this album zip to my library

    how to extract the audio of a zip file? if it helps I'm trying to add this album zip to my library

    Let's say you have a zipped audio collection (audio.zip) containing mp3 files. And you are at a Terminal prompt.
    List the files in the zip archive
    unzip -l audio.zip (that is ell)
    Extract all mp3 audio files into a new home directory folder called mymusic
    unzip -d ~/mymusic audio.zip \*.mp3
    Variations of the above will depend the zip contents, and internal structure. If the zipped audio collection was gzipped, or someone used rar on it, then the extraction process will be different.

  • I need a script that copies the filename into the file

    I need a script that copies the filename into 4th column of each line in the text doc file.
    I have over 2000 different file names each containing 6 columns and ~50-100 rows.
    I can do this manually using this script:
    awk '{print $1"\t"$2"t\"$3"\t <name> \t"$6}'
    But I would like an automation command or script. Is there any command that I can use instead of <name> that will copy the filename into the column?
    Thanks
    Monica

    Oops, I forgot the redirect to a file. It's not a good idea to edit files in place. A script could fail and you're left with at least one file ruined. It's better to create new files then delete the old files.
    for file in *; do
        while read col1 col2 col3 col4 col5 col6; do              
            printf "%s\t%s\t%s\t%s\t%s\n" $col1 $col2 $col3 $file $col6
        done < $file > n$file
    done
    You could narrow the files listed such as
    for file in *.tsv
    and redirect the new files to another directory. Such as
    done < $file > /absolute/path/to/directory/$file

  • Get only the filename not the full path of the file.

    hi to all..
    how can i get only the filename of the file not the full path and to be placed on a textinput.?
    example:
    when i'browse the file and select sample.txt
    "C:\Users\user\Desktop\folders\sample.txt" this will be inputted on the textinput.
    however, what i want to have is when i'browse and select a file..
    textinput should only contain "sample".
    does anyone knows how to do it?

    Hi cyrus@adobe,
    How are you getting the full path of the file when you browse, I dont think for security reasons the Flash Player will aloow to do so. You can only get the file name not the full path of the file when you browse.
    Are you using Flex4..?? I am not sure whether this is possible in Flex4..However if you are getting full path and if you wanted to show only the filename then you can just use theString class split function to acehive this..
    var fullPath:String = "C:\Users\user\Desktop\folders\sample.txt";
        var splitPath:Array = fullPath.split("\");
        textInput.text = splitPath[splitPath.length-1];
    Thanks,
    Bhasker

  • Error in reading the contents of a zip file

    EHello Experts,
    I want to read the contents of a zip file.I have written the following program which reads the contents of a file named "index.xml" which resides in ReadZip.zip.My problem is , it is reading only the first line of that file & after that it is giving this error.
    java.io.IOException: Stream closed
    at java.util.zip.ZipInputStream.ensureOpen(ZipInputStream.java:43)
    at java.util.zip.ZipInputStream.getNextEntry(ZipInputStream.java:67)
    at components.ReadZipFile2.main(ReadZipFile2.java:26)
    public class ReadZipFile2 {
        public static void main(String args[]) {
            try {
                FileInputStream fis = new FileInputStream("C:\\ReadZip.zip");
                ZipInputStream zis = new ZipInputStream(fis);
                ZipEntry ze;
                while ((ze = zis.getNextEntry()) != null) {
                    System.out.println(ze.getName());
                    if (ze.getName().equals("ReadZip/index.xml")) {
                        long size = ze.getSize();
                        if (size > 0) {
                            System.out.println("Length is " + size);
                            BufferedReader br = new BufferedReader(
                                    new InputStreamReader(zis));
                            String line;
                            while ((line = br.readLine()) != null) {
                                System.out.println(line);
                            br.close();
            } catch (IOException e) {
                e.printStackTrace();
    }It seems that zis is getting close after reading the first entry of file.I am unable to guess the reason for this.Please help.Thanx in advance.

    [redacted confused advice]
    [_Compressing and Decompressing Data using Java - with many code samples_|http://java.sun.com/developer/technicalArticles/Programming/compression/|Yes Virginia, there really are code samples]

  • Change the filename of an uploaded file.

    I have created a web app so that users can login to a secure zone and upload a file to a specific folder in my business catalyst site.  I would like to append the user's credentials to the filename.  I can see how to capture the user's firstname and lastname but I am not sure how to make it part of the filename.
    The filename at the moment is named liked this 4628132_311455_New Text Document.txt with a timestamp and id auto appended to the original uploaded filename.  I would like to add some kind of user identifier to this name at form submission.

    Hi,
    I cannot see a workaround and doesn't appear possible as the system will only append the unique ID which cannot be customized at this stage. 
    Kind regards,
    -Sidney

  • I have really slow internet, i bought OS X mountain lion & tried for days to download it. my internet cuts every time & the download restarts from the beginning is thr a way to download the software as a "zip" file or from a link not app store?

    I have really slow internet, i bought OS X mountain lion & tried for days to download it. my internet cuts every time & the download restarts from the beginning is thr a way to download the software as a "zip" file or from a link not app store?

    MacBook Pro
    https://discussions.apple.com/community/notebooks/macbook_pro 
    https://discussions.apple.com/community/mac_os/mac_os_x_v10.7_lion?view=discussi ons
    http://www.apple.com/support/macbookpro
     Take it somewhere that has better broadband. The best you can do sometimes is invest in new modem that works with your system instead of the rental etc in most cases.
    Do a Safe Boot.
    Make sure your firewall is set properly. Don't use 3rd party. AV software can get in the way.
    Make sure you are getting the service and a clean strong modem signal - slow is one thing but if it drops off and can't maintain a connection you have hardware issues, not software - and upgrade to a new OS doesn't tend to improve, it may even not work with older networking equipment once you do get it.
     I agree and think electronic only goes too far. And when you do get it: burn the package and manually set it aside first before running the intaller! make a flash memory installer, put it on DVDs too.

  • Receiver determination based on the filename of the incoming xml file

    hi folks,
    is it possible to base the receiver determination from the filename (pattern) of the incoming xml file?
    suppose, if the filename is partner1.xml, then the receiver determination has a condition of partner1.  in this case, the message is received by partner1.
    any advise please?
    thanks!
    -lex

    Hi Lex,
    You can use Enhanced Receiver Determination for this. Do your normal mapping from source to target. And another mapping for the receiver determination. In that mapping you can use the UDF for Dynamic Configuration and set the filename as the receiver service name.
    Use the following blog for Enhanced Receiver Determination:
    /people/venkataramanan.parameswaran/blog/2006/03/17/illustration-of-enhanced-receiver-determination--sp16
    This blog explains the usage of Dynamic Configuration:
    /people/michal.krawczyk2/blog/2005/11/10/xi-the-same-filename-from-a-sender-to-a-receiver-file-adapter--sp14
    Regards,
    Sanjeev.

  • I need to start and stop logging based on a digital input event(or analog if necessary), log data for several seconds prior to the event, and have the data file close at the end of event and increment the filename for the next logging event.

    I don't know if this can be done with VI Logger or need to use Labview V7.1.

    After browsing through the VI Logger User Manual, it looks like the triggering that you are hoping to accomplish is possible. However, incrementing the filename for the next logging event is not going to be possible. VI Logger does exactly what its name tells - logs data. I don't think the automation that you are hoping to accomplish is possible.
    For help with setting up your application, if you do choose to stay with VI Logger, make sure to chek out the Getting Started with VI Logger Manual.
    Best of luck.
    Jared A

  • How to extract a folder (and its contents) from inside a zip file?

    There is a zip file which contains a folder inside it. The folder itself contains a few files. I would need to know how to extract the folder (with its contents) from inside a zip file.
    I have found a few unzipping code samples which show how to handle a folder inside a zip file. An example is shown below:
    public static void extract(String workingDirectory, byte[] zipFile)
    throws Exception {
    ByteArrayInputStream byteStream = new ByteArrayInputStream(zipFile);
    ByteArrayOutputStream out = new ByteArrayOutputStream();
    ZipInputStream zipStream = new ZipInputStream(byteStream);
    ZipEntry zipEntry = null;
    String nameZipEntry = null;
    byte[] contentZiphttp://forum.java.sun.com/post!default.jspa?forumID=31#
    Click for code tagsEntry = null;
    boolean isDirectory = false;
    int indexFileSeparator = -1;
    String directory = null;
    String fileName =  null;
    while ( (zipEntry = zipStream.getNextEntry()) != null )
                nameZipEntry = workingDirectory + File.separator + zipEntry.getName();
                isDirectory = zipEntry.isDirectory();
                if (isDirectory) {
    File file = new File(nameZipEntry);
    file.mkdirs();
                else
                    // read zipEntry
                    byte[] buf = new byte[1024];
                    int c = 0;
                    while ( (c = zipStream.read(buf)) != -1)
                        out.write(buf, 0, c);
                    indexFileSeparator = nameZipEntry.lastIndexOf(File.separator);
                    directory = nameZipEntry.substring(0, indexFileSeparator);
                    fileName =  nameZipEntry.substring(indexFileSeparator+1,nameZipEntry.length());
                    FileSystemTools.createFile(directory, fileName, out);
                    out.reset();
                    zipStream.closeEntry();
            zipStream.close();
            byteStream.close();
    }The code sample which deals with the part where the zipEntry is a directory creates a directory with the same path and name. (highlighted in bold)
    Another similar variation is:
    File file = new File(dirDestiny.getAbsolutePath() + File.separator + zipEntry.getName() );
    if(zipEntry.isDirectory())
          file.mkdirs();When the code creates a directory for the folder, does it unzip the contents inside the folder as well?
    If not, how do I extract the files inside the folder?

    Have you already tried to see if the sample code you downloaded works or not? Maybe if you try out the code yourself you can see if it extracts files from a directory within a zip file?
    I like to use pkzip. It is a command line compression/uncompression tool that can be used from a batch file. If you assignment involves unzipping large amount of zip files on a regular basis, I recommend taking a look at pkzip.

Maybe you are looking for

  • Help with a "AT NEW" statement

    I am debugging at some code and I am trying to understand the following statement <i>LOOP AT it_data_item_final INTO st_data_item_final. MOVE st_data_item_final-waers TO w_waers. <b>AT NEW xblnr."xblnr." budat xblnr waers.</b>       MOVE-CORRESPONDIN

  • Problem with trash

    i have problem emptying my trash,it saws up that there are some files that i cannot delete,how can i fix it?

  • Reporting services Installation with Globalization Locale Settings

    Hi Guys,          We have a problem in report Subscription using File share date format rendering.The File share works properly.But the data showing in Subscription "pdf"  like Date format not displaying properly based on different countries. It alwa

  • External swf madness

    I am trying to load an external swf into a movie clip, but when I test the file the movie is playing much larger than what I made the movie clip loader. I add the following script to the swf movie that I am trying to load, and it successfully keeps i

  • How the protected finalize method is called by garbage collector

    Dear All, I have a double regarding the calling mechanism of finalize method. The access specifier of finalize method is protected, not only that if a class overrides this method then also the finalize method can be protected in the subclass of Objec