How to ensure file is not binary...

When I allow users to upload files to my server through a servlet, I want to make sure they are only uploading text files.
How do I do this?
Thanks

All files are binary. So you want to limit the uploads to something that you call "text". So you have to decide what that means. I am guessing that since you don't realize there is a question here, you are equating "text" with "ASCII characters". Let's start there... would you permit accented characters as well? If so would you accept them in CP-1252 and ISO-8859-1 encodings, or would you restrict them to only one? And would you permit Russian text, or Japanese text -- and in which encodings? Bear in mind that HTTP uploads just consist of bytes, and there is no way to know the encoding of a file that's uploaded to you.
Anyway, the answer is that you have to decide what bytes constitute "text" and scan the uploaded files to see if they contain anything besides those bytes.

Similar Messages

  • How to fix file could not be found

    How to fix file could not be found

    The instructions are in the videos on the page. Scroll down to the videos and click the big arrow in the middle of the image. It might not be obvious that those are videos.

  • How open a file and not showing window?

    I write a script to do some work automatic,
    for Indesign script, its application open method could open a file and not showing window,
    the open method has a parameter [ShowingWindow] (if true, show the document window).
    That is good a feature for me.
    But with Illustrator, the application open method hasn't the same feature.
    Open
    (files as String,
    [documentColorSpace as AiDocumentColorSpace],
    [options as Object])
    and for OpenOptions properties, there is not useful information for me.
    Is there any other methods could do that?
    Any help is greatly appreciated.

    Thank for your reply.

  • GRC:AC:SPM: How to ensure SAP_ALL in not deleting FF log files?

    Hi Guys,
    Due to some critical business requirements occuring occasionally, I wanted to set up a FF ID having SAP_ALL. This would be besides the other FF IDs, which I have already created for each of the modules. I.e basically this SAP_ALL FFID would be to handle emengency and cross module tasks.
    Now, I have a limitation here that this FFID having SAP_ALL profile may do anything and then even clear all the logs for what all it did (as it would have unlimited access to even delete the logs for FFID usage). Any workaround solution for this?
    Regards.
    Hersh.
    http://www.linkedin.com/in/hersh13

    Zaheer is exactly correct. The main point of SAP_ALL is to be (almost) unrestricted and that is why it is recommended to not assign it.
    Although Firefighter allows you to gain elevated access in a controlled manner, if you just assign firefighter ID's SAP_ALL then you will be allowing that access in the systems effectively, invalidating any controls which you had there previously.
    There are loads of ways of trimming SAP_ALL but I would generate a role based on the SAP_ALL template and de-activate the key authorisations (GRCFF_0001).
    Simon

  • How to ensure File Read Adapter handles like SQLLOADER's TRAILING NULLCOLS

    I have to read a CSV file which has a specific format but sometimes the trailing columns values can be missing and i would like to handle it in such way that they values are treated as null. This is similar to the SQLLoader's TRAILING NULLCOLS clause.
    Currently if my data is as shown below:
    As-Of Date,As-Of-Time,Bank ID,Bank Name,State,Acct No,Acct Type,Acct Name,Currency,BAI Type Code,Tran Desc,Debit Amt,Credit Amt,0 Day Flt Amt,1 Day Flt Amt,2+ Day Flt Amt,Customer Ref No,Value Date,Location,Bank Reference,Tran Status,Descriptive Text,Descriptive Text1,Descriptive Text2,Descriptive Text3,Descriptive Text4,Descriptive Text5,Descriptive Text6
    20061031,23:59:00,121000248,"WELLS FARGO BANK, N.A.",CA,4121235097,COMMERCIAL DDA,Silicon Image - A/P,USD,475,CHECK PAID,55.86,0,0,0,0,51689,10/31/2006,,IA000313659233,POSTED,,,,,,,
    20061031,23:59:00,121000248,"WELLS FARGO BANK, N.A.",CA,4121235097,COMMERCIAL DDA,Silicon Image - A/P,USD,475,CHECK PAID,1377.57,0,0,0,0,51685,10/31/2006,,IA000210166161,POSTED
    20061031,23:59:00,121000248,"WELLS FARGO BANK, N.A.",CA,4121235097,COMMERCIAL DDA,Silicon Image - A/P,USD,475,CHECK PAID,1435,0,0,0,0,51621,10/31/2006,,IA000627084628,POSTED
    It reads the first row properly , but when in encounters the second row POSTED column , it tries to find the terminated column and since it is not present it reads data from the next line until it finds a comma.
    This is not the way i would like to handle it.
    We get around 1000-2000 records in that CSV from the Bank and they cant change the way they are sending the file. So , please help in resolving this issue.
    Thanks
    Sridhar

    Hi thanks for the reply
    well i've been having a play around but haven't got it to work yet,
    Here's what i have so far
    private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {
             BufferedReader  sb = new BufferedReader();
           sb.append(""+jTextField1.setText()+",");
           sb.append(""+jFormattedTextField1.setText()+"\n");
           sb.append(""+jTextField2.setText()+",");
           sb.append(""+jFormattedTextField2.setText()+"\n");
           sb.append(""+jTextField3.setText()+",");
           sb.append(""+jFormattedTextField3.setText()+"\n");
           sb.append(""+jTextField4.setText()+",");
           sb.append(""+jFormattedTextField4.setText()+"\n");
           sb.append(""+jTextField5.setText()+",");
           sb.append(""+jFormattedTextField5.setText()+"\n");
           ReadFromFile(sb.toString());
        private void ReadFromFile(String s) {
            try {
            BufferedReader in = new BufferedReader(new FileReader("/users/data.txt"));
            String str;
            while ((str = in.readLine()) != null) {
                Process(str);
            in.close();
        } catch (IOException e) {
        }// TODO add your handling code here:
                    }im thinking the problem is the parts that say sb.append but i don't know what to in it's place?

  • How to change File Kind (not "how to assign an application to open a file?)

    I build the toc.ncx file (part of the ePub setup) automatically, based on user input and source file content. It's fine, except that the file Kind (as shown in Finder Preview, for example) is Plain Text.
    The Kind should be Unix Executable File (the actual description is "zmedia-type="application/x-dtbncx+xml") in order for the file to function correctly with the rest of the ePub generation.
    I could set the file Kind in the program (I think!), except that I do not know what the code for such a Kind is.
    Can you help?
    Message was edited by: David Neale1
    Message was edited by: David Neale1

    To make the file a Unix executable can be done as follows:
    Open the Terminal application in the Utilities folder and enter the following:
    sudo chmod 755 /pathto/filename
    Press RETURN. Enter your admin password at the prompt; it will not be echoed. Alternatively put a space after "755" then drag the file's icon into the Terminal window.
    If you want the Unix icon simply set the file's default application to Terminal by selecting the file then Press COMMAND-I to open the Get Info window. Change the default application in the Open With section. If you want all .ncx files the same way then click on the Change All button.

  • Encoding different file types to binary

    Hi, im writing an application which takes different file types and then encodes them to be sent down a noisy channel, after random effects the data must be decoded back to binary. I have done the algorthims for encoding and decoding binary but i dont know how convert the file types to binary. (files such as jpgs and mp3 and txt)

    ...i know how to do the encoding on binary ...
    ...im not sure how to do this...Maybe you could start by explaining the problem in detail to yourself such that you understand it, then come back and tell us.
    Are you concerned about a difference between a JPG file vs a text file? Text files, in the context you are describing, can be treated as binary just as easily. Use a FileInputStream to read it and you get bytes just like any other file.

  • File does not exists error

    I am using OAS 10g. Looking through HTTP_Server logs, I see the following error repeating very often. I am a Forms developer unfamiliar with Java. Do you have ideas about this error or any suggestions as to what steps I should take:
    [Fri Jun 19 17:06:58 2009] [error] [client 123.123.123.123] [ecid: 1245445618:456.456.456.45:4224:4256:265,0] File does not exist: c:/oracle/ora904astest/forms90/java/java/awt/KeyboardFocusManager.class
    [Fri Jun 19 17:06:59 2009] [error] [client 123.123.123.123] [ecid: 1245445619:456.456.456.45:4224:5208:169,0] File does not exist: c:/oracle/ora904astest/forms90/java/java/awt/KeyboardFocusManager.class
    [Fri Jun 19 17:07:00 2009] [error] [client 123.123.123.123] [ecid: 1245445620:456.456.456.45:4224:5464:243,0] File does not exist: c:/oracle/ora904astest/forms90/java/oracle/forms/registry/default.dat
    [Fri Jun 19 17:07:49 2009] [error] [client 123.123.123.123] [ecid: 1245445669:456.456.456.45:4224:1308:275,0] File does not exist: c:/oracle/ora904astest/forms90/java/oracle/ewt/alert/resource/AlertBundle_en_US.class
    [Fri Jun 19 17:07:49 2009] [error] [client 123.123.123.123] [ecid: 1245445669:456.456.456.45:4224:4784:315,0] File does not exist: c:/oracle/ora904astest/forms90/java/oracle/ewt/alert/resource/AlertBundle_en_US.class
    [Fri Jun 19 17:07:49 2009] [error] [client 123.123.123.123] [ecid: 1245445669:456.456.456.45:4224:4388:254,0] File does not exist: c:/oracle/ora904astest/forms90/java/oracle/ewt/alert/resource/AlertBundle_en_US.properties
    Thank you.

    Refer following note on MetaLink:
    ID: 238979.1 How to Prevent "File does not exist" Errors in the error_log?
    Thanks
    Shail

  • ITunes tells me "Could not be used because the original file could not be found. Would you like to locate it?"  I can locate it and all my other music, but can only open one song at a time.  How do I set it to open all my music whenever I want it?

    iTunes tells me my song selection: "Could not be used because the original file could not be found. Would you like to locate it?"  I can locate it and all my other music, but can only open one song at a time.  How do I set it to open all my music whenever I want?
    Message was edited by: Woildbill

    I just spent several hours dealing with this when switching to a new PC. It was extremely frustrating as I knew my files were on my external HD but no matter how many times I copied my old iTunes folder over the files were still missing...because dummy me had forgotten to "unhide folders" on my new PC and my old files were actually stored in a hidden folder created long long ago.
    This is how I did it on Windows 7 with iTunes 10
    1. Look in iTunes Advanced Preferences to see where iTunes is saving files. (Edit, Preferences, Advanced)
         Example: C:/Users/Woildbill/My Music/iTunes/Music
    2. Ensure you are able to see hidden files - Control Panel, Folder Option, View, Show Hidden Files
    3. Use Your Computer's Search Function to Locate the Missing File (Start, Search, type name of song - I started my search in "My Music" folder but be sure to expand to entire Computer if not found right away)
    4. In Search Results, right-click found folder and select properties. This will tell you where the file is actually stored.
    5. Use Windows Explorer (right-click start) to navigate to the location of the file. It is likley your other missing files are in the same location.
    6. In Windows Explorer, copy the newly located files to the iTumes location from Step 1 and everything should work again.
    Hope this helps!

  • It was found an error in the OPF file: The file is not stored in Cover guide . To ensure the navigation on Kindle devices, you should correct that.

    Hi,
    I have found errors when uploading the ePub 3 fixed layout classic ebooks on Apple.
    It was found an error in the OPF file: The file is not stored in Cover <guide>. To ensure the navigation on Kindle devices, you should correct that.
    Please help me?
    Thanks,
    CK

    Thank you but please help me solve this problem.
    Kindly look at the below error:
    It was found an error in the OPF file: The file is not stored in Cover <guide>. To ensure the navigation on Kindle devices, you should correct that.
    Please let me know how it will solve.
    Thanks,
    CK

  • App binary file does not correspond to folios in Adobe Viewer

    I created an app in several different language versions, all connected to the same multi-layer/lingual InDesign files. In Adobe Viewer they look and work fine, however Apple just approved the English language binary update and the app is entirely in Spanish. I tried re-exporting the .ipa file from a previous version (one that was already published in English albeit with bugs- hence the update submission)  and this too shows in Spanish. I tried re-saving all InDesign files with the English language layer turned on and exporting a new version, but once again it shows in Spanish. My client is understandibly very upset as the app is time-sensitive and if we have to wait another week for Apple approval we are in big trouble.
    What is going on and how can I fix it?

    Ok, I'll try it, but I don't understand why this happened in the first place. The English app was ready to be exported before the Spanish version had been sent to "create app," and so in my understanding the exported file should have coincided with what I see in the viewer.
    Melanie De Jesus
    Mobile: +39 392 9932197
    SAY DESIGN s.a.s.
    Il giorno 21/lug/2013, alle ore 16:10, Neil Enns - Adobe <[email protected]> ha scritto:
    Re: App binary file does not correspond to folios in Adobe Viewer
    created by Neil Enns - Adobe in Digital Publishing Suite - View the full discussion
    Are you making a Single Edition application? If so simply changing the layer state and redownloading the application isn't enough. You have to go to the Create App menu item again and go through the App Builder wizard for it to pick up the changed files.
    Neil
    Please note that the Adobe Forums do not accept email attachments. If you want to embed a screen image in your message please visit the thread in the forum to embed the image at http://forums.adobe.com/message/5524671#5524671
    Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/5524671#5524671
    To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/5524671#5524671. In the Actions box on the right, click the Stop Email Notifications link.
    Start a new discussion in Digital Publishing Suite by email or at Adobe Community
    For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • How to find file type (Binary/Ascii) using Java IO

    Hi
    I want to find whether the file is binary file or not.
    Can any one please help.
    Thanks,
    Joy

    Encephalopathic wrote:
    I'm no IO expert, but aren't all files binary?Yes.
    I think what the OP is after is how to tell if a file contains only characters (e.g. ASCII characters). This can be done by reading the file and checking if every byte is a valid ASCII character more or less. An example would be limiting byte values to 9 (tab), 10 (LF), 12 (FF), 13 (CR), and 32-127.

  • [svn:osmf:] 15934: Ensure OSMFPlayer doesn' t get stuck on preloader if configuration file is not present.

    Revision: 15934
    Revision: 15934
    Author:   [email protected]
    Date:     2010-05-06 14:18:56 -0700 (Thu, 06 May 2010)
    Log Message:
    Ensure OSMFPlayer doesn't get stuck on preloader if configuration file is not present.
    Modified Paths:
        osmf/trunk/apps/samples/framework/OSMFPlayer/src/org/osmf/player/preloader/Preloader.as
        osmf/trunk/libs/ChromeLibrary/org/osmf/chrome/application/ChromeApplication.as

    Thank you for the replies,
    unfortunately it's not the router. I usually switch on/off the router if I'm not at home. Therefore  I have ruled out from the very beginning the router. And I'd rule out an upgrade of  arch's packages as well.  I installed->upgraded all packages  after a fresh installation of arch,  and then I started the configuration...
    ewaller, nice "How to"
    Cheers
    Last edited by bradomyn (2011-09-13 10:59:39)

  • Some of the songs I have downloaded onto i tunes won't play when I select it to do so.  The error message I get is "The song could not be used because the original file could not be found.  Would you like to locate it?"  How can I get my songs to play?

    Some of the songs I have downloaded into i tunes won't play when I select it to do so.  The error message I get is "The song can not be used because the original file can not be found.  Would you like to locate it?"  When I select yes I'm sent to a screen that has my i tunes library listed.  When I select the song in question I'm asked if I would like to open the song.  When I select this option I get nothing.  The songs I have downloaded must be somewhere because they are listed in my i tunes library and on the screen I've been sent to.  I can't the songs to play however.  This is not true of all of my songs but it is true of quite a few of them.  Actually, one song is too many.    How do I get my music to play that seems to be locked up somewhere in the computer?

    Presuming they're on your computer, right click on them and then follow the prompts to locate hte file on your computer.

  • TS3694 When trying to update or restore my Iphone I get an error message saying...could not be restored because firmware file is not compatible.  What is this and how can it be resolved?

    When trying to restore or update my Iphone 4 it errors out with message:..."could not be restored because the firmware file is not compatible."  How do I resolve this?

    Ask him if he has 'jailbroken' the ipod touch. Some jailbreaking firmware resets it to Ipad firmware and so it is very difficult to restore as itunes simply doesnt recognise it for what it is. It's Apple's solution to try and stop mass jailbreaking.

Maybe you are looking for