GFS and Struts

2 views
Skip to first unread message

Lukasw44

unread,
May 12, 2010, 1:55:11 PM5/12/10
to GoogleFileService
Where i can find tutorial how to use GFS and STRUTS 1??

Can i use ActionForm and Action to use GFS???

I Writing ActionServlet like this:
package datastore2;



import java.io.InputStream;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
import java.util.Date;
/**
* @author Deepak Kumar
* @Web http://www.roseindia.net
* @Email rosein...@yahoo.com
*/

/**
* Struts File Upload Action Form.
*
*/
public class dodaj extends Action
{
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response) throws Exception{
uploadFormBean myForm = (uploadFormBean)form;
// Process the FormFile
FormFile myFile = myForm.getTheFile();
String fileOwner = "root";
Date data = new Date();

String fileId = "23323";
String contentType = myFile.getContentType();
String fileName = myFile.getFileName();
int fileSize = myFile.getFileSize();
//byte[] fileData = myFile.getFileData();

InputStream stream = myFile.getInputStream();

fileSize = DatastoreUtils.insertGoogleFile(fileId, fileOwner,
fileName, contentType, stream );
return mapping.findForward("success");
}
}



And upload form bena :
public class uploadFormBean extends ActionForm
{
private FormFile theFile;

/**
* @return Returns the theFile.
*/
public FormFile getTheFile() {
return theFile;
}
/**
* @param theFile The FormFile to set.
*/
public void setTheFile(FormFile theFile) {
this.theFile = theFile;
}
}


But i have problem to use it

Any Idea what i do wrong to write file ???

--
You received this message because you are subscribed to the Google Groups "GoogleFileService" group.
To post to this group, send email to google-fi...@googlegroups.com.
To unsubscribe from this group, send email to google-file-ser...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-file-service?hl=en.

Reply all
Reply to author
Forward
0 new messages