Content type problem for 'does not appear to be a proper arcive'

Hi all,
The following code will create a ZipOutputStream using ByteArrayOutputStream (not FileOutputStream) and attach the outputstream to a MIME multipart email using ByteArrayDataSource (so the file never exists physically).
It works and sends the email but the zip 'does not appear to be a valid archive' even though it looks about the right size. If I do the same and use FileOutputStream to create a physical file it works OK. I think it is an issue with the content type, or maybe this just isn't possible!
I have tried:
byteArray.toByteArray(),
byteArray.toString().getBytes() and application/zip & application/unknown.
Can anyone help or suggest an alternative way to create a 'in-memory' zip file that can then be emailed?
Many thanks
    // Specify files to be zipped
                                                             String[] filesToZip = new String[3];
                                                             filesToZip[0] = "C:\\Program Files\\NetBeans3.6\\firstfile.txt";
                                                             filesToZip[1] = "C:\\Program Files\\NetBeans3.6\\secondfile.txt";
                                                             filesToZip[2] = "C:\\Program Files\\NetBeans3.6\\thirdfile.txt";
                                                             byte[] buffer = new byte[18024];
                                                             // Specify zip file name
                                                              String zipFileName= eq_rt.getReportName() + ".zip";
                                                             try {
                                                               // Create ZipOutputStream to store the FileOutputStream
                                                               //ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
                                                               ByteArrayOutputStream byteArray = new ByteArrayOutputStream();                                                             
                                                               ZipOutputStream out = new ZipOutputStream(byteArray);                                                              
                                                               // Set the compression ratio
                                                               out.setLevel(Deflater.DEFAULT_COMPRESSION);
                                                               // iterate through the array of files, adding each to the zip file
                                                               for (int a = 0; a < filesToZip.length; a++) {
                                                                 System.out.println(a);
//                                                                 // Associate a file input stream for the current file
                                                                 FileInputStream in = new FileInputStream(filesToZip[a]);
                                                                 // This ROCKS as it is passing a array into the text file .getBytes() seems
                                                                 // to be the KEY in getting ByteArrayInputStream to WORK
                                                                 String strSocketInput = "TAIWAN";
                                                                 ByteArrayInputStream baIn = new ByteArrayInputStream(strSocketInput.getBytes());
                                                                 //ByteArrayInputStream baIn = new ByteArrayInputStream( getAttachementNoFormat(eq_rt.getStoredProc() ) );                                                               
                                                                 // Add ZIP entry to output stream.
                                                                 out.putNextEntry(new ZipEntry(filesToZip[a]));
                                                                 // Transfer bytes from the current file to the ZIP file
                                                                 int len;
                                                                 while ((len = baIn.read(buffer)) > 0)
                                                                 out.write(buffer, 0, len);
                                                                 // Close the current entry
                                                                 out.closeEntry();
                                                                 // Close the current file input stream
                                                                 baIn.close();                                                   
                                                              // DataSource sourcezip = new FileDataSource(zipFileName);
                                                               //DataSource sourcezip = new ByteArrayDataSource(byteArray.toByteArray(), zipFileName, "application/octet-stream");   
                                                                DataSource sourcezip = new ByteArrayDataSource(byteArray.toByteArray(), zipFileName, "application/octet-stream" );
                                                               // Create a new MIME bodypart
                                                               BodyPart attachment = new MimeBodyPart();
                                                               attachment.setDataHandler(new DataHandler(sourcezip));
                                                               attachment.setFileName(zipFileName);                       
                                                               /* attach the attachemnts to the mail */
                                                               multipart.addBodyPart(attachment);                                                                
                                                               // Close the ZipOutPutStream
                                                               out.close(); 

Many thanks Dr Clap. Moving the Closing the ZipOutputStream before I attached it to the email solved my problem.
                                      /* Close the ZipOutPutStream (very important to close the zip before you attach it to the email) Thanks DrClap */
                                                                out.close();                                                    
                                                                /* Create a datasource for email attachment */
                                                                // DataSource sourcezip = new FileDataSource(zipFileName);
                                                                DataSource sourcezip = new ByteArrayDataSource(byteArray.toByteArray(), zipFileName, "application/zip" );
                                                                /* Create a new MIME bodypart */
                                                                BodyPart attachment = new MimeBodyPart();
                                                                attachment.setDataHandler(new DataHandler(sourcezip));
                                                                attachment.setFileName(zipFileName);                       
                                                                /* attach the attachemnts to the mail */
                                                                multipart.addBodyPart(attachment);  

Similar Messages

  • HT3625 I have a 2012 macBook Pro 13" and the option "Use audio port for" does not appear at all in the sound menu. why is this? im running  mountain Lion 10.8.2

    I have a 2012 macBook Pro 13" and the option "Use audio port for" does not appear at all in the sound menu. why is this? im running  mountain Lion 10.8.2

    Because line-in has been removed.
    It does allow for an Apple headset with mic., but I don't know if it would work with third-party ones.
    You'll need to use a Griffin iMic or similar to use line-in via a USB port.
    The same goes for the 15" retina, the newest MBA and the new iMac (whenever it finally arrives).

  • SP 2013 ECT - Created an External Content Type in SPD But Not Appearing in BCS

    Hello Community,
    I have created an External Content Type in SP Designer 2013, and the connection and operations all seem to work fine, but the ECT List throws an access error, and when I check the BCS Service Application the ECT doesn't even appear in the list.  Has
    anyone else ever seen this kind of problem and if so please brovide guidance and examples for resolving it.
    Thanks!
    Tom
    Tom Molskow - Senior SharePoint Architect - Microsoft Community Contributor 2011 and 2012 Award -
    Linked-In - SharePoint Gypsy

    Hi Tom,
    Have you created external content type from SharePoint designer 2013 successfully prevously?
    And was it displayed in BCS service applicaiton previously?
    Have you executed "External Content Type Operations" and saved it back successfully in SharPoint Designer like the following article?
    Please check if it is related to the permission issue by using SharePoint Farm Administrator account to create this external content type.
    If all above don't solve the issue, please check the ULS log for more information for troubleshooting when create the external content type.
    http://www.c-sharpcorner.com/UploadFile/anavijai/create-external-content-type-using-sharepoint-designer-2013/
    Thanks,
    Daniel Yang
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Daniel Yang
    TechNet Community Support

  • When I try to email a picture the space to type a comment with the picture does not appear

    When I try to email a picture with a message, the space to type a message does not appear. Why?

    If you get no response after starting 6 threads on an issue, it's worth looking at question you are asking over and over. Perhaps you need to re-think it. Perhaps you need to give more details - how you're emailing, with what apps, a fuller description of the issue and perhaps even a screenshot, anything that might help other people understand what you're asking.
    Regards
    TD

  • Ruby (Furigana) does not appear

    Problem:
    Ruby does not appear above kanji.
    Question:
    What settings might I need to change to get ruby to appear above the selected character?
    Screenprint:

    Hi Peter.
    Your questions led me to the right setting.
    Yes, I have the Japanese version of ID installed (in the same location as the English as far as I know).
    The World Ready Composer was turned off. I turned it on and no changes occurred, but beneath that command is the Japanese Paragraph Composer.
    When I turned the Japanese Paragraph Composer on, the ruby text (small characters that appear above the kanji) appeared as in the screenshot provided below:
    This is solved.
    Thank you.

  • Hi all, I upgraded my MBP to Lion , but on the screen where i need to type my password, click  on my photo and it does not appear the place for me to type my password and it stay stuck there. Can anyone solve this problem for me?

    Hi all, I upgraded my MBP to Lion , but on the screen where i need to type my password, click  on my photo and it does not appear the place for me to type my password and it stay stuck there. Can anyone solve this problem for me?

    Reboot the machine holding Command and r keys down, you'll boot into Lion Recovery Partition
    In there will be Disk Utility, use that to select your Lion OS X Partition and Repair Permissions.
    After that is done reboot the machine and see if you can log in.
    If not repeat the above steps to get into Lion Recovery, get online and reinstall Lion again, it will overwrite the installed version and hopefully after that it wil work.
    Reboot and try again.
    If not follow my steps to create a Snow Leopard Data Recovery drive, then option boot from it and grab a copy of your files off the machine.
    Then reinstall all your programs onto the external drive like setting up a new machine, then use Disk Utility to erase the entire internal boot drive (select the drive media on the far left, not the partiton slightly indented) format Option: GUID , 1 partition OS X Extended and then use Carbon Copy Cloner to clone the external to the newly formatted internal drive. Once that is finished reboot and disconnect the external drive.
    Once you go that, boot into Snow Leopard and update to 10.6.8, use the AppStore and option click on Purchases and download Lion again and install.
    Lots of work, but there is no Lion disks.
    https://discussions.apple.com/message/16276201#16276201

  • A word document was emailed to me.  I can open the document without a problem.  Is there a way for me to type on the document.... to fill out the form?  When I click the fields, the virtual keyboard does not appear.

    A word document was emailed to me.  I can open the document without a problem on my iPad 2.   Is there a way for me to type on the document.... to fill out the form?  When I click the fields, the virtual keyboard does not appear.

    If you want to edit a word document then you will need an app on your iPad that supports word so that you can copy them to it via 'open in' e.g. Apple's Pages app or a third-party app such as Documents To Go or QuickOffice HD

  • Good night recently my iphone 4s was exchanged for a new one because was defective and was in warranty. the problem is that now I try to use the same apple id on itunes and applications while had bought the old iphone does not appear and I think should ap

    good night recently my iphone 4s was exchanged for a new one because was defective and was in warranty. the problem is that now I try to use the same apple id on itunes and applications while had bought the old iphone does not appear and I think should appear. Can someone help?

    ?

  • Been using an Avastor HDX-800 for storage and backup, also a SUPERDISK for smaller stuff; recently the SUPERDISK does not appear on the screen, and the light blinks while you hear it spin, also the Avastor has started to have the same problem, both USB

    Been using an Avastor HDX-800 for storage and backup, also a SUPERDISK for smaller stuff; recently the SUPERDISK does not appear on the screen, and the light blinks while you hear it spin, also the Avastor has started to have the same problem, both USB conncected, both worked well before, but both now spinning, blinking, and not showing up on the screen as before,
    Interestingly they both appear in the System Profiler, but just not working the same as before
    I have tried other USB ports, but the same responce,

    yes I did reset the PRAM, but no benefit, still the same problem
    my usb devices are:  keyboard, mouse, printer, SD-USB-M3, and LaCie d2 DVDRW:
    the mouse and printed are plugged into the keyboard: i have tried to move, these around, and have even tried just the mouse, printer and SD-USB-M3, but still the same problem
    here is a cut and paste of the current  "System Profiler>Hardware>USB"   (usb device tree)
    USB Bus:
      Host Controller Location:          Built In USB
      Host Controller Driver:          AppleUSBOHCI
      PCI Device ID:          0x0026
      PCI Revision ID:          0x0000
      PCI Vendor ID:          0x106b
      Bus Number:          0x18
    Hub in Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x1002
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    HL-1270N series:
      Version:          1.00
      Bus Power (mA):          100
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Brother
      Product ID:          0x0008
      Serial Number:          L9J286292
      Vendor ID:          0x04f9
    Basic Optical Mouse:
      Version:          0.00
      Bus Power (mA):          100
      Speed:          Up to 1.5 Mb/sec
      Manufacturer:          Microsoft
      Product ID:          0x0084
      Vendor ID:          0x045e
    Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          250
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x0204
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    SuperDisk USB 120MB drive:
      Version:          0.0e
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Imation
      Product ID:          0x0002
      Vendor ID:          0x0718
    Hub in Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x1002
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    HL-1270N series:
      Version:          1.00
      Bus Power (mA):          100
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Brother
      Product ID:          0x0008
      Serial Number:          L9J286292
      Vendor ID:          0x04f9
    Basic Optical Mouse:
      Version:          0.00
      Bus Power (mA):          100
      Speed:          Up to 1.5 Mb/sec
      Manufacturer:          Microsoft
      Product ID:          0x0084
      Vendor ID:          0x045e
    Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          250
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x0204
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    HL-1270N series:
      Version:          1.00
      Bus Power (mA):          100
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Brother
      Product ID:          0x0008
      Serial Number:          L9J286292
      Vendor ID:          0x04f9
    Basic Optical Mouse:
      Version:          0.00
      Bus Power (mA):          100
      Speed:          Up to 1.5 Mb/sec
      Manufacturer:          Microsoft
      Product ID:          0x0084
      Vendor ID:          0x045e
    Apple Pro Keyboard:
      Version:          1.22
      Bus Power (mA):          250
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Mitsumi Electric
      Product ID:          0x0204
      Vendor ID:          0x05ac  (Apple Computer, Inc.)
    SuperDisk USB 120MB drive:
      Version:          0.0e
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          Imation
      Product ID:          0x0002
      Vendor ID:          0x0718
    USB Bus:
      Host Controller Location:          Built In USB
      Host Controller Driver:          AppleUSBOHCI
      PCI Device ID:          0x0026
      PCI Revision ID:          0x0000
      PCI Vendor ID:          0x106b
      Bus Number:          0x19
    LaCie d2 DVDRW USB:
      Capacity:          451.76 MB
      Removable Media:          Yes
      Detachable Drive:          Yes
      BSD Name:          disk2
      Version:          0.00
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          LaCie
      OS9 Drivers:          No
      Product ID:          0x1011
      Serial Number:          FFFFFFFFFFFF
      S.M.A.R.T. status:          Not Supported
      Vendor ID:          0x059f
    LaCie d2 DVDRW USB:
      Capacity:          451.76 MB
      Removable Media:          Yes
      Detachable Drive:          Yes
      BSD Name:          disk2
      Version:          0.00
      Bus Power (mA):          500
      Speed:          Up to 12 Mb/sec
      Manufacturer:          LaCie
      OS9 Drivers:          No
      Product ID:          0x1011
      Serial Number:          FFFFFFFFFFFF
      S.M.A.R.T. status:          Not Supported
      Vendor ID:          0x059f

  • exception-type in web.xml does not appear to work

    WLS 60 SP1 (#101616)
              <exception-type> in web.xml does not appear to work. WLS shows standard
              "Internal error 500" page instead of a custom error page. The custom error
              page is shown if <error-code> is used instead of <exception-type>.
              Any ideas? Thanks
              

    Can you show me some of your code? This works for me.
    Also, you say that you are working with 6.0sp3. Are you sure? sp3 hasn't been
    released yet, except in a very limited beta. (I believe only internally, but I
    could be wrong about that.)
    David
    [email protected] wrote:
    Hi all,
    I have created a very simple servlet and an index.html file with a link
    to it, then packaged it into a WAR file with the appropriate web.xml and
    ias-web.xml files. I then created an application.xml file referencing
    only this servlet and adding a context root. After deployment via
    "iasdeploy deployapp simple.ear" and cycling the web server, I can reach
    the welcome file (index.html) correctly
    -"http://localhost/NASApp/simple". When I attempt to follow the link to
    the servlet ("simple servlet") the URL ends
    up as "http://localhost/NASApp/SimpleServlet" whereas it should be
    http://localhost/NASApp/simple/SimpleServlet If I type that url in, the
    servlet executes fine.
    I've deployed this into Tomcat and get the behavior I expect. It appears
    that the element in the application.xml file is ignored by
    iAS.
    I'm using iAS SP3 on Win2k (same problem on NT).
    This is such a basic behavior that I can't believe this is an existing
    bug. I must be doing something wrong...
    Any ideas?
    Thanks in advance,
    -Glen
    Files are attached.
    Name: simple.ear
    simple.ear Type: application/x-unknown-content-type-ear_auto_file
    Encoding: base64
    Description: filename="simple.ear"

  • Since my last firefox update, I have been unable to type an email - the text box does not appear when I press 'reply' , or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] s

    Hello. Since my last firefox update, I have been unable to type an email - the box within which one would usually type does not appear when I press 'reply' to a received email, or press 'compose'. The email provider is '123-reg.co.uk. I have been using both firefox and the provider ['webfusion Ltd/webmail123] successfully for well over a year. The provider says it is a browser problem. I can still add an attachment to the email header, which successfully can be sent, but the recipient gets my standard email 'signature' with font messages and the attachment. Can anyone help? My email addresses are [email protected] [this is the one with the issue] and [email protected] in English
    == today

    My daughter has had her Razr for about 9 months now.  About two weeks ago she picked up her phone in the morning on her way to school when she noticed two cracks, both starting at the camera lens. One goes completely to the bottom and the other goes sharply to the side. She has never dropped it and me and my husband went over it with a fine tooth comb. We looked under a magnifying glass and could no find any reason for the glass to crack. Not one ding, scratch or bang. Our daughter really takes good care of her stuff, but we still wanted to make sure before we sent it in for repairs. Well we did and we got a reply from Motorola with a picture of the cracks saying this was customer abuse and that it is not covered under warranty. Even though they did not find any physical damage to back it up. Well I e-mailed them back and told them I did a little research and found pages of people having the same problems. Well I did not hear from them until I received a notice from Fed Ex that they were sending the phone back. NOT FIXED!!! I went to look up why and guess what there is no case open any more for the phone. It has been wiped clean. I put in the RMA # it comes back not found, I put in the ID #, the SN# and all comes back not found. Yet a day earlier all the info was there. I know there is a lot more people like me and all of you, but they just don't want to be bothered so they pay to have it fix, just to have it do it again. Unless they have found the problem and only fixing it on a customer pay only set up. I am furious and will not be recommending this phone to anyone. And to think I was considering this phone for my next up grade! NOT!!!!

  • Moved recording does not appear as content

    I recently encountered an issue where, when I attempt to move a recording from under a meeting to a Shared Content folder, either the list of Shared Content folders does not appear or, when the move is "successful", the recording is bot listed in the new content location.  Interestingly, if I change the URL of the destination location from "content" to "meeting"  (http://server/admin/content/sco/... to http://server/admin/meeting/sco/...), the recordng will appear in the list.  Unfortunately, under this "meeting view", there is not any editing or offline functionality.  The link for the recording continues to be functional and playback works normally, but the recording is otherwise treated as a "meeting" rather than content.
    Using the API, I used the sco-by-url XML action to compare the values of an affected recording to an unaffected one, but could not find anything that appeared unusual.  Both recordings were identified as the "content" type.
    Atempting to edit the video, or make an offline copy, by modifying the usual link produced by clicking those button with the appropriate url-path generates a "Not Found - The selected resource does not exist" error.  The editing and offline copy processes worked normally prior to the move.
    We are currently running Adobe Connect version 8.2.0.0:
    package=8.2.0.1.156.20110921.963902
    installer=8.2.0.0.11.20110728.938680
    fmg=8.2.0.0.4.20110906.879854
    fms=8.1.1.0.2.20110427.772086
    presenter=8.2.0.0.6.20110824.924658
    cps=8.2.0.1.3.20110920.973276
    mssql=8.1.0.0.10.20110311.8644363
    teleintercall=8.1.0.0.2.20110207.776631
    telepremierena=8.1.0.0.21.20110412.882778
    telepremiereemea=8.1.0.0.21.20110412.882778
    cpshelp=8.2.0.0.4.20110908.964981
    addins=8.2.0.0.3.20110831.929039
    dbscripts=8.2.0.0.23.20110818.956139
    teleavaya=8.1.0.0.4.20110412.882778
    telecisco=8.1.0.0.17.20110412.882778
    telemeetingone=8.1.0.0.2.20110207.776631
    telephonyservice=8.1.0.0.8.20110228.847019
    tomcat=6.0.29
    stunnel=4.28
    Is there another mechanism Adobe Connect discerns between the content and meetings so far as under with view/interface it will be displayed?  Is there a way to correct this behavior for existing files?  Thanks for any insight.
    Eric

    Having support look at this may be the best option. Since you are using your own server, you should call 866-335-2256, wait for the second round of prompts and then option 1. Have your support contract number ready when you call.

  • Video will not play on BBC site error message this content does not appear to be working .Help

    I have bbc news as home page after i updated to firefox 10 if i try to play embedded video i get the eror message [this content does not appear to be working] Help

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether the problem is caused by third-party software that loads automatically at startup or login, by a peripheral device, or by corruption of certain system caches. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode and log in to the account with the problem. Note: If FileVault is enabled on some models, or if a firmware password is set, or if the boot volume is a software RAID, you can’t do this. Ask for further instructions.
    Safe mode is much slower to boot and run than normal, and some things won’t work at all, including sound output and  Wi-Fi on certain models. The next normal boot 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, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • TS3716 iPod classic does not appear in iTunes for Mac since updating to 11.0.

    iPod classic does not appear in iTunes for Mac since updating to 11.0. It appears on the desktop and iTunes starts up when the iPod is connected, but it does not appear in a form so that I can manage its contents.

    Mike:
    Just had the very same problem.  iPod Classic shows up on my desktop but not in iTunes (11.0.1).  I tried restarting iPod while connected as suggested elsewhere.  Didn't work.  What did seem to work however was, while the iPod is connected (and on the desktop) restart iTunes.  Once it restarted it was there and synching.  I also, before restart, made sure that auto-synching was set up in iTunes preferences (under devices).
    Try this.  May work for you as well.

  • I have installed the font Broadway on my computer and it works in Microsoft Word but does not appear in the font list in InDesign.  How can I fix this problem?

    I have installed the font Broadway on my computer and it works in Microsoft Word but does not appear in the font list in InDesign.  How can I fix this problem?

    Start by rebooting the computer. If that doesn't work, search for adobefnt*.lst and delete all instances where * becomes a 2-digit number.

Maybe you are looking for