How to get the file from FileUpload in GWT - mysql

I'm working with GWT and have a FileUpload widget wrapped in a FormPanel along with a textbox and submit button.
I want to write the data to a MySQL database. I can successfully make a call to the server and insert the fileName, name, etc to the DB. But how do I upload the actual file to the database? I'm having a hard time understanding how to do this.

I recommend the Apache FileUpload library to parse the incoming file using a standard HTTPServlet.
If you're using just the MySQL java library, here's a code snippet on how to take the file stream from the upload and pass it to your MySQL code:
java insert Blob as ByteArrayOutputStream get ClassCastException

Generally the uploading in GWT works as in any J2E project with a Servlet. See example here
However, I suggest using GWTUpload which offers better features (MultiUploading, progress bar ...) and can be easily integrated.

First read the file and store its content into a String variable, say fileData.
Then have a BLOB, CLOB or TEXT type column in your table and insert the fileData value into that column.
For more info on the data types mentioned above, have a look at these: http://dev.mysql.com/doc/refman/5.0/en/blob.html
MySQL TEXT vs BLOB vs CLOB

Related

How do I use Pentaho spoon to push data from MySQL database to facebook webpage

1) I have already made transformation mapping for getting data from specific MySQL (Table Input) and convert it as Text File output.
2) Also I have created a facebook developer account page and trying to figure out how the Facebook API works to push data from MYsql to facebook.
3) would appreciate if transformation mapping can be provided. Also I would not like to use XML, instead I would like to use JSON.
Already the msql table is converted to csv file, but I am not sure how to post the csv file to facebook or is there a way to connect mysql table to facebook directly. Please share your ideas or transformation mapping. Thanks
I would Assuemm you are familiar with Facebook Development API to do all actions like post,get and so on.
You have a step called "REST CLIENT STEP" in Pentaho.
you will have an API url to post the data that you want from mySQL. There several methods GET PUT POST DELETE
Also set the Application Format to Json (XML,JSON etc).
I used to read data from FB using REST Client by using GET Method. Work around.

User login in codeigniter with out database and use json format instead of

I am trying to login and register users in codeigniter but with out using database and I would like to use json instead of database.
Can anyone give me small example that how can we do this in codeigniter.
I have worked login and registration with using database and I don't have idea of how we can do by using json.
Can any one explain me and give me small example of how to do that.
Well yes you can use helper FILE and save data in in that file.
To write / Access data, you need to do few steps:
Load File Helper
Check if File exists
Get all text and decode in array (I assume you will store in JSON format)
Fetch username/password and verify
Add new username/password in that array
Convert into JSON and save in file

What does a JSON file do?

I went through previous posts on SO and some of the answers say that a JSON file is used to send data from server to client.
Well that seems to be okay but then we can create package.json, Apidoc.json, manifest.json which do not interact with the client and server
So can someone tell me what actually is a JSON file?
JSON stands for JavaScript Object Notation. It is used to describe a data structure in a simple format. It can be a plain text file, which may be used to pass data from the server to a client, but it could be equally used to hold and consume that data at the same layer e.g. you could have a configuration file at the client side which is read an interpreted by your application.
Note also that JSON does not need to be held in a file; you could create a string variable with JSON data in it and pass this from one method to another without ever storing it in a file.
The tag definition in Stack Overflow can be found here https://stackoverflow.com/tags/json/info and further information can be found here https://www.json.org/.
JSON is a file format, just like CSV. Just because CSV is used with Microsoft Excel, does not mean that is all it is used for (just like with JSON). Just because it is common to get info from a server in JSON format, does not mean that is all JSON is used for. Do some googling before asking a question like this on Stack Overflow.
Here is an intro to JSON. JSON Intro W3Schools

Beego: how to create an upload form to store files in MySQL database?

I am making an web application in beego. I am new in both go and beego. I want to save a pdf file in mysql database. In php we can easily do that but in beego i am facing issue.
Mysql type blob is used to store pdf files. But in go blob is not a valid type. So what should i use in go? I face this issue while making model for the mysql table.
How to parse html form to get the pdf file? I know only about GetString and GetInt functions but how to get file type from html form in beego controller?
According to the Beego Documentation, you can use GetFile:
file, header, err := ctrlr.GetFile("input_name_in_markup")
You must apply the enctype="multipart/form-data" attribute to your HTML forms so the files get uploaded.
Also, the BLOB type can be represented as a []byte slice. Some packages define a Blob type that is aliased from []byte - e.g: type Blob []byte. You'll have to check the package you're working with to verify it has one. Otherwise, use []byte.

XPages: Generate CSV file and attach to mail

I'm trying to generate a csv file (specifically an .ics) and attach this to an email.
The Email is composed via an SSJS-Function.
An opportunity could be to generate the csv file, save it to a document and attach this to the email .
I tried to generate the csv file via an XAgent in a XPage (like this http://www.wissel.net/blog/d6plinks/SHWL-8248MT) and get a handle of the output, but with no success.
Do you know a possibility to manage this?
Any help is greatly appreciated!
Thanks in advance!
you are looking at 2 tasks:
Create a csv / ics file
Send this as attachment
For #1 you can use a Stringbuilder or a Printwriter or whatever. However an ics file is actually not a CSV file, but an iCalendar format. To generate it I highly recommend ical4j. In any case whatever you write -> don't create a file. Use a PrintWriter (for the CSV) that uses a ByteArrayOutputStream (or directly for ICS4J), so the result is a ByteArray in memory.
For #2 The ONE mental step you must make is AWAY from "the Notes way" trying to deal with embedded objects etc. You create a MIME message (there are snippets on OpenNTF) and create a mimepart. There you can use setContentFromBytes and you have your attachment.
Pro tip (to make your life easier): create a Java class with a function that takes an outputstream as parameter that generates the file for you. This way you can test it in Eclipse (or the Domino Designer Java view) without having to run preview and with full debugging support (you simply provide a file-output stream for testing and write to a file - or to System.out)