I'm facing a simple problem I would like to get a local path from the end-user of my web application. I need only that and not to actually upload a file. (I know there are fileUpload tags in seam or in Primefaces but I just need the local full path as I'm uploading directly to Picasa Web Albums via the Google API)
In other words I would like to bind some kind of html tag : input type="file" to a bean property (I notice that the JSF tag h:inputText tag doesn't have a type attribute) Any ideas?
Env : JBoss AS 5.1, JSF1.2, Seam 2.2, Primefaces 1.1
Edit : here is my working solution
Thanks to the answers, I implemented the use-case of uploading a file directly to Picasa
<h:form prependId="false" enctype="multipart/form-data">
<s:fileUpload id="fileUpload"
data="#{picasa.incomingFile}"
contentType="#{picasa.fileType}"/>
<h:inputText id="albumId"
value="#{picasa.albumId}" />
<h:commandLink action="#{picasa.upload()}"
value="Upload">
<f:param name="s"
value="#{subjectHome.id}"/>
</h:commandLink>
</h:form>
and the component code
@Name("picasa")
public class PicasaService {
@Logger private Log log;
private PicasawebService service;
private InputStream incomingFile;
private String fileType;
private String albumId;
@Create
public void setUp()
{
service = new PicasawebService("picasaService");
try {
service.setUserCredentials("xxx@yyyy.zzz", "password");
} catch (AuthenticationException e) {
e.printStackTrace();
}
}
public void upload()
{
URL albumUrl;
PhotoEntry returnedPhoto;
try {
albumUrl = new URL("https://picasaweb.google.com/data/feed/api/user/default/albumid/" + albumId);
MediaStreamSource myMedia = new MediaStreamSource(incomingFile , this.fileType);
returnedPhoto = service.insert(albumUrl, PhotoEntry.class, myMedia);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServiceException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
This way, it seems to me that the file is not transferred twice (one from end-user machine to my web app's server and from there to picasa WA server).
Hope this helps