本文整理汇总了Java中com.liferay.portal.kernel.upload.UploadPortletRequest.getFileAsStream方法的典型用法代码示例。如果您正苦于以下问题:Java UploadPortletRequest.getFileAsStream方法的具体用法?Java UploadPortletRequest.getFileAsStream怎么用?Java UploadPortletRequest.getFileAsStream使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.liferay.portal.kernel.upload.UploadPortletRequest
的用法示例。
在下文中一共展示了UploadPortletRequest.getFileAsStream方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addAlbum
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void addAlbum(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
long artistId = ParamUtil.getLong(uploadPortletRequest, "artistId");
String name = ParamUtil.getString(uploadPortletRequest, "name");
int year = ParamUtil.getInteger(uploadPortletRequest, "year");
InputStream inputStream = uploadPortletRequest.getFileAsStream("file");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Album.class.getName(), uploadPortletRequest);
try {
AlbumServiceUtil.addAlbum(
artistId, name, year, inputStream, serviceContext);
SessionMessages.add(request, "albumAdded");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
}
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof AlbumNameException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/albums/edit_album.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例2: addArtist
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void addArtist(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
String name = ParamUtil.getString(uploadPortletRequest, "name");
String bio = ParamUtil.getString(uploadPortletRequest, "bio");
InputStream inputStream = uploadPortletRequest.getFileAsStream(
"file");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Artist.class.getName(), uploadPortletRequest);
try {
ArtistServiceUtil.addArtist(
name, bio, inputStream, serviceContext);
SessionMessages.add(request, "artistAdded");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect); }
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof ArtistNameException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/artists/edit_artist.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例3: addArtist
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void addArtist(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
String name = ParamUtil.getString(uploadPortletRequest, "name");
String bio = ParamUtil.getString(uploadPortletRequest, "bio");
InputStream inputStream = uploadPortletRequest.getFileAsStream(
"file");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Artist.class.getName(), uploadPortletRequest);
try {
ArtistServiceUtil.addArtist(
name, bio, inputStream, serviceContext);
SessionMessages.add(request, "artistAdded");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect); }
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof ArtistNameException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/artists/edit_artist.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例4: addTempFileEntry
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
protected void addTempFileEntry(ActionRequest actionRequest, String folderName) throws Exception {
_log.info("addTempFileEntry()");
UploadPortletRequest uploadPortletRequest = _portal.getUploadPortletRequest(actionRequest);
checkExceededSizeLimit(uploadPortletRequest);
long groupId = ParamUtil.getLong(actionRequest, "groupId");
deleteTempFileEntry(groupId, folderName);
InputStream inputStream = null;
try {
String sourceFileName = uploadPortletRequest.getFileName("file");
inputStream = uploadPortletRequest.getFileAsStream("file");
String contentType = uploadPortletRequest.getContentType("file");
_layoutService.addTempFileEntry(groupId, folderName, sourceFileName, inputStream, contentType);
} catch (Exception e) {
UploadException uploadException = (UploadException) actionRequest.getAttribute(WebKeys.UPLOAD_EXCEPTION);
if (uploadException != null) {
Throwable cause = uploadException.getCause();
if (cause instanceof FileUploadBase.IOFileUploadException) {
if (_log.isInfoEnabled()) {
_log.info("Temporary upload was cancelled");
}
}
if (uploadException.isExceededFileSizeLimit()) {
throw new FileSizeException(cause);
}
if (uploadException.isExceededUploadRequestSizeLimit()) {
throw new UploadRequestSizeException(cause);
}
} else {
throw e;
}
} finally {
StreamUtil.cleanUp(inputStream);
}
}
示例5: updateArtist
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void updateArtist(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
long artistId = ParamUtil.getLong(uploadPortletRequest, "artistId");
String name = ParamUtil.getString(uploadPortletRequest, "name");
String bio = ParamUtil.getString(uploadPortletRequest, "bio");
InputStream inputStream = uploadPortletRequest.getFileAsStream(
"file");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Artist.class.getName(), uploadPortletRequest);
try {
ArtistServiceUtil.updateArtist(
artistId, name, bio, inputStream, serviceContext);
SessionMessages.add(request, "artistUpdated");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
}
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof ArtistNameException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/artists/edit_artist.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例6: addSong
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void addSong(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
String name = ParamUtil.getString(uploadPortletRequest, "name");
InputStream songInputStream = uploadPortletRequest.getFileAsStream(
"songFile");
String songFileName = uploadPortletRequest.getFileName("songFile");
InputStream lyricsInputStream =
uploadPortletRequest.getFileAsStream("lyricsFile");
String lyricsFileName = uploadPortletRequest.getFileName(
"lyricsFile");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Song.class.getName(), uploadPortletRequest);
try {
SongServiceUtil.addSong(
albumId, name, songFileName, songInputStream,
lyricsFileName, lyricsInputStream, serviceContext);
SessionMessages.add(request, "songAdded");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
}
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof SongNameException ||
e instanceof DuplicatedSongException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/songs/edit_song.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例7: updateSong
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void updateSong(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
long songId = ParamUtil.getLong(uploadPortletRequest, "songId");
String name = ParamUtil.getString(uploadPortletRequest, "name");
InputStream songInputStream = uploadPortletRequest.getFileAsStream(
"songFile");
String songFileName = uploadPortletRequest.getFileName("songFile");
InputStream lyricsInputStream =
uploadPortletRequest.getFileAsStream("lyricsFile");
String lyricsFileName = uploadPortletRequest.getFileName(
"lyricsFile");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Song.class.getName(), uploadPortletRequest);
try {
SongServiceUtil.updateSong(
songId, albumId, name, songFileName, songInputStream,
lyricsFileName, lyricsInputStream, serviceContext);
SessionMessages.add(request, "songUpdated");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
}
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof SongNameException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/songs/edit_song.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例8: updateAlbum
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void updateAlbum(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
long artistId = ParamUtil.getLong(uploadPortletRequest, "artistId");
String name = ParamUtil.getString(uploadPortletRequest, "name");
int year = ParamUtil.getInteger(uploadPortletRequest, "year");
InputStream inputStream = uploadPortletRequest.getFileAsStream("file");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Album.class.getName(), uploadPortletRequest);
try {
AlbumServiceUtil.updateAlbum(
albumId, artistId, name, year, inputStream, serviceContext);
SessionMessages.add(request, "albumUpdated");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
}
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof AlbumNameException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/albums/edit_album.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例9: addSong
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void addSong(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
String name = ParamUtil.getString(uploadPortletRequest, "name");
InputStream songInputStream = uploadPortletRequest.getFileAsStream(
"songFile");
String songFileName = uploadPortletRequest.getFileName("songFile");
InputStream lyricsInputStream =
uploadPortletRequest.getFileAsStream("lyricsFile");
String lyricsFileName = uploadPortletRequest.getFileName(
"lyricsFile");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Song.class.getName(), uploadPortletRequest);
try {
SongServiceUtil.addSong(
albumId, name, songFileName, songInputStream,
lyricsFileName, lyricsInputStream, serviceContext);
SessionMessages.add(request, "songAdded");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
}
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof SongNameException ||
e instanceof DuplicatedSongException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/songs/edit_song.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}
示例10: updateAlbum
import com.liferay.portal.kernel.upload.UploadPortletRequest; //导入方法依赖的package包/类
public void updateAlbum(ActionRequest request, ActionResponse response)
throws Exception {
UploadPortletRequest uploadPortletRequest =
PortalUtil.getUploadPortletRequest(request);
long albumId = ParamUtil.getLong(uploadPortletRequest, "albumId");
long artistId = ParamUtil.getLong(uploadPortletRequest, "artistId");
String name = ParamUtil.getString(uploadPortletRequest, "name");
int year = ParamUtil.getInteger(uploadPortletRequest, "year");
InputStream inputStream = uploadPortletRequest.getFileAsStream("file");
ServiceContext serviceContext = ServiceContextFactory.getInstance(
Album.class.getName(), uploadPortletRequest);
try {
AlbumServiceUtil.updateAlbum(
albumId, artistId, name, year, inputStream, serviceContext);
SessionMessages.add(request, "albumUpdated");
String redirect = ParamUtil.getString(
uploadPortletRequest, "redirect");
response.sendRedirect(redirect);
}
catch (Exception e) {
SessionErrors.add(request, e.getClass().getName());
if (e instanceof AlbumNameException ||
e instanceof PrincipalException) {
response.setRenderParameter(
"jspPage", "/html/albums/edit_album.jsp");
}
else {
response.setRenderParameter("jspPage", "/html/error.jsp");
}
}
}