Topic
  • 11 replies
  • Latest Post - ‏2013-07-07T18:04:03Z by kevintap
asian123
asian123
46 Posts

Pinned topic File Upload

‏2013-02-28T12:12:54Z |
Hi ,

I am suppose to upload a file (xls) and read the data from .xls file and store it in database .

i try to do some sample model with the procedure mentioned in below link
http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Handling_file_attachments_using_IBM_WebSphere_Portlet_Factory

but i am not able to upload the file and it shows the errors !

could you please provide me any sample example for my above scenario ?

-Asian123
Updated on 2013-03-05T15:31:25Z at 2013-03-05T15:31:25Z by mburati
  • mburati
    mburati
    2576 Posts

    Re: File Upload

    ‏2013-02-28T14:59:41Z  
    What are the errors that it shows?

    If you post a sample (with no confidential info or intellectual property) showing what you're having trouble with, it might make it easier for someone to quickly spot what's wrong with it.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • asian123
    asian123
    46 Posts

    Re: File Upload

    ‏2013-03-01T06:34:48Z  
    • mburati
    • ‏2013-02-28T14:59:41Z
    What are the errors that it shows?

    If you post a sample (with no confidential info or intellectual property) showing what you're having trouble with, it might make it easier for someone to quickly spot what's wrong with it.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Actually i above link is a sample example for the file(.xls) upload and open a file(.xls) which is uploaded that has given in the Internet. I thought this excersize will help to do my actual code requirement .

    My requirement is : I need to upload a file(.xls) from local machine and convert it as XML/records which should able to insert those updated row's in the database.

    Anyway the sample example which i am trying to run is attached and first it was problem with missing jar files , and after adding jar's still i am getting some other error . Pls see the attachemnt for jar's , model and error !

    Could you pls provide me if you have any better example for above scenario ?

    Thank you!
    -Asian123
  • mburati
    mburati
    2576 Posts

    Re: File Upload

    ‏2013-03-01T13:49:52Z  
    • asian123
    • ‏2013-03-01T06:34:48Z
    Actually i above link is a sample example for the file(.xls) upload and open a file(.xls) which is uploaded that has given in the Internet. I thought this excersize will help to do my actual code requirement .

    My requirement is : I need to upload a file(.xls) from local machine and convert it as XML/records which should able to insert those updated row's in the database.

    Anyway the sample example which i am trying to run is attached and first it was problem with missing jar files , and after adding jar's still i am getting some other error . Pls see the attachemnt for jar's , model and error !

    Could you pls provide me if you have any better example for above scenario ?

    Thank you!
    -Asian123
    That error doesn't look like it's coming from a WEF model / webapp, but from some other standalone java class?

    Have you tried the Spreadsheet Import builder to import the spreadsheet into XML instead of trying to hand code it?

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • asian123
    asian123
    46 Posts

    Re: File Upload

    ‏2013-03-04T06:41:36Z  
    • mburati
    • ‏2013-03-01T13:49:52Z
    That error doesn't look like it's coming from a WEF model / webapp, but from some other standalone java class?

    Have you tried the Spreadsheet Import builder to import the spreadsheet into XML instead of trying to hand code it?

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Hi,

    You can run the model which i have attached in my last post . the error i am getting is in the line
    bytesString = new javax.xml.bind.annotation.adapters.HexBinaryAdapter().marshal(bytes);

    i dont have idea how my requirement can be achived with spreadsheet import builder ?

    file upload is mandatory (it will be uploaded from client machine ) and after that i need to save this file somewhere and read this uploaded file to convert as xml (records ).

    could you please give me any sample example if you have ?

    -Asian123
  • mburati
    mburati
    2576 Posts

    Re: File Upload

    ‏2013-03-04T14:02:26Z  
    • asian123
    • ‏2013-03-04T06:41:36Z
    Hi,

    You can run the model which i have attached in my last post . the error i am getting is in the line
    bytesString = new javax.xml.bind.annotation.adapters.HexBinaryAdapter().marshal(bytes);

    i dont have idea how my requirement can be achived with spreadsheet import builder ?

    file upload is mandatory (it will be uploaded from client machine ) and after that i need to save this file somewhere and read this uploaded file to convert as xml (records ).

    could you please give me any sample example if you have ?

    -Asian123
    Right, you would still use the File Upload builder to upload the file, but then use the Spreadsheet Import builder to import the file into an XML representation that you could then use to pass the data to your provider that handles the SQL calls against the database.

    The API call that you're making that you're getting the error from is not WEF specific. Rather than debug that, it may be more straightforward to use the above mentioned builders to do the work for you.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • asian123
    asian123
    46 Posts

    Re: File Upload

    ‏2013-03-05T09:15:14Z  
    • mburati
    • ‏2013-03-04T14:02:26Z
    Right, you would still use the File Upload builder to upload the file, but then use the Spreadsheet Import builder to import the file into an XML representation that you could then use to pass the data to your provider that handles the SQL calls against the database.

    The API call that you're making that you're getting the error from is not WEF specific. Rather than debug that, it may be more straightforward to use the above mentioned builders to do the work for you.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
    Can i have one sample example model for this ? i tried to do this i kept one "uploadAttachemnt" html tag to FileUpload builder and "upload" html tag to Button builder . in the button builder submit action , i have called spreadshet import.execute builder method and passed File name as 'File to Import' section in spreadsheetImpot builder ..it is giving me null pointer exception.

    And also when i upload any file for example c:/book.xls , when i get this through

    String fileName = waa.getRequestInputs().getInputValue("uploadAttachments");

    it is giving fileName = c:/book1.xls

    this i am passing to spreadsheet import builder and calling its execute method. it is giving me nulll pointer exception.

    could you pls pls give me some code example for this ? am struggling to make this to work

    -Asian123
  • mburati
    mburati
    2576 Posts

    Re: File Upload

    ‏2013-03-05T15:31:25Z  
    • asian123
    • ‏2013-03-05T09:15:14Z
    Can i have one sample example model for this ? i tried to do this i kept one "uploadAttachemnt" html tag to FileUpload builder and "upload" html tag to Button builder . in the button builder submit action , i have called spreadshet import.execute builder method and passed File name as 'File to Import' section in spreadsheetImpot builder ..it is giving me null pointer exception.

    And also when i upload any file for example c:/book.xls , when i get this through

    String fileName = waa.getRequestInputs().getInputValue("uploadAttachments");

    it is giving fileName = c:/book1.xls

    this i am passing to spreadsheet import builder and calling its execute method. it is giving me nulll pointer exception.

    could you pls pls give me some code example for this ? am struggling to make this to work

    -Asian123
    I don't personally have a single sample that does both today, or time to write a new one today, but it looks like there's a File Upload sample and a spreadsheet (excel) import sample on the WEF Wiki Samples page at: http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Web_Expereince_Factory_Samples_Categorized

    I suggest trying to get both of those running individually, and then combine them to do what you're trying to do.

    It's not clear how/why you're getting an upload filepath of c:\ Typically the file upload builder should upload the file to the configured file upload subfolder of the WAR or to a subfolder of that configured WAR subfolder, if specified in the File Upload builder inputs.

    If you post a sample (with no confidential info or intellectual property) showing what you're having trouble with, it might make it easier for someone to quickly spot what's wrong with it.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.
  • asian123
    asian123
    46 Posts

    Re: File Upload

    ‏2013-07-03T14:08:20Z  
    • mburati
    • ‏2013-03-05T15:31:25Z
    I don't personally have a single sample that does both today, or time to write a new one today, but it looks like there's a File Upload sample and a spreadsheet (excel) import sample on the WEF Wiki Samples page at: http://www-10.lotus.com/ldd/pfwiki.nsf/dx/Web_Expereince_Factory_Samples_Categorized

    I suggest trying to get both of those running individually, and then combine them to do what you're trying to do.

    It's not clear how/why you're getting an upload filepath of c:\ Typically the file upload builder should upload the file to the configured file upload subfolder of the WAR or to a subfolder of that configured WAR subfolder, if specified in the File Upload builder inputs.

    If you post a sample (with no confidential info or intellectual property) showing what you're having trouble with, it might make it easier for someone to quickly spot what's wrong with it.

    I hope that info helps,
    ..Mike Burati
    http://www-10.lotus.com/ldd/pfwiki.nsf/
    The postings on this site are my own and do not necessarily represent the positions, strategies, or opinions of IBM.

    Hi,

    I am able to upload a file and make it an XML though 'FileUpload' builder and 'Spreadsheet Import' builder.

    but in this 'Spreadsheet Impot' builder i have to provide sample .xls file so that when i will upload , it will take this sample .xls file as reference.

     

    But now i dont have any sample xls file so that i can provide to this builder , the excel file i am trying to upload has dynamic colums which means i dont have specified column to make a sample .xls file so that i can provide this sample .xls file to the 'Spreadsheet Impot' builder.

    how i can read data when i upload a .xls file ? any other alternate solution for this ? means after browse the file , though a button i need to take this file and read it and make this as XML.

     

    Pls help me in this !

    -Asian123

     

     

  • kevintap
    kevintap
    749 Posts

    Re: File Upload

    ‏2013-07-03T15:15:50Z  
    • asian123
    • ‏2013-07-03T14:08:20Z

    Hi,

    I am able to upload a file and make it an XML though 'FileUpload' builder and 'Spreadsheet Import' builder.

    but in this 'Spreadsheet Impot' builder i have to provide sample .xls file so that when i will upload , it will take this sample .xls file as reference.

     

    But now i dont have any sample xls file so that i can provide to this builder , the excel file i am trying to upload has dynamic colums which means i dont have specified column to make a sample .xls file so that i can provide this sample .xls file to the 'Spreadsheet Impot' builder.

    how i can read data when i upload a .xls file ? any other alternate solution for this ? means after browse the file , though a button i need to take this file and read it and make this as XML.

     

    Pls help me in this !

    -Asian123

     

     

    The Spreadsheet Import builder requires that you provide a sample .xls file in order to generate a schema.  It sounds like your end goal is to import the data in the uploaded spreadsheet into a database table.  What is the structure of your database table?  I assume that your database has some schema which you want your uploaded spreadsheets to adhere to.  Would it be possible to generate a sample spreadsheet with all of the possible columns that you might expect in the uploaded spreadsheets?

  • asian123
    asian123
    46 Posts

    Re: File Upload

    ‏2013-07-04T06:40:02Z  
    • kevintap
    • ‏2013-07-03T15:15:50Z

    The Spreadsheet Import builder requires that you provide a sample .xls file in order to generate a schema.  It sounds like your end goal is to import the data in the uploaded spreadsheet into a database table.  What is the structure of your database table?  I assume that your database has some schema which you want your uploaded spreadsheets to adhere to.  Would it be possible to generate a sample spreadsheet with all of the possible columns that you might expect in the uploaded spreadsheets?

    My end goal is to upload a file from 'FileUpload' builder and read it as an Xml , so that i can update the data into DB. i cannot directly update the data with the XML to DB because it is not in the same DB  schema structure.

    The downloaded data is a dynamic data formation of the columns in the excel sheet , so that i cannot except exactly how many columns it will have , like based on , for example , Terms , how many i have in the DB that many colums i need to generate dynamically in XML and that XML will be input of Spreadsheet Expot builder. After download this data , i can modify some of the fields , and need to upload and convert it as XML so that again i can do the appropriate formation .

     

    Pls help me in this ! i think spreadsheet import builder is no more expected for dynamic Excel upload...means we dont have idea how many columns will be there in the excel...

     

    Pls provid me alternate solution for this ! or how directly read Excel sheet when i upload?

     

    -Suma

  • kevintap
    kevintap
    749 Posts

    Re: File Upload

    ‏2013-07-07T18:04:03Z  
    • asian123
    • ‏2013-07-04T06:40:02Z

    My end goal is to upload a file from 'FileUpload' builder and read it as an Xml , so that i can update the data into DB. i cannot directly update the data with the XML to DB because it is not in the same DB  schema structure.

    The downloaded data is a dynamic data formation of the columns in the excel sheet , so that i cannot except exactly how many columns it will have , like based on , for example , Terms , how many i have in the DB that many colums i need to generate dynamically in XML and that XML will be input of Spreadsheet Expot builder. After download this data , i can modify some of the fields , and need to upload and convert it as XML so that again i can do the appropriate formation .

     

    Pls help me in this ! i think spreadsheet import builder is no more expected for dynamic Excel upload...means we dont have idea how many columns will be there in the excel...

     

    Pls provid me alternate solution for this ! or how directly read Excel sheet when i upload?

     

    -Suma

    The Spreadsheet Import builder can be used here.  You could just provide a dummy spreadsheet to the Spreadsheet Import builder to generate a schema against (and then ignore that schema).  There is no requirement that the actual spreadsheet file that it reads maintain the same format as the one used to generate a schema.  This will give you access to the raw XML data in your application, and you can manipulate it as necessary.