@PUT @Path("16x16") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response post16x16Image(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { return this.putImage(Filename.FILENAME_SMALL_ICON, uploadedInputStream, body.getMediaType()); }
@PUT @Path("50x50") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response post50x50Image(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { return this.putImage(Filename.FILENAME_BIG_ICON, uploadedInputStream, body.getMediaType()); }
@PUT @Path("icon.jpg") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putIcon(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { try { SelfServiceMetaDataUtils.ensureDataXmlExists(this.id); } catch (IOException e) { throw new WebApplicationException(e); } RepositoryFileReference ref = new RepositoryFileReference(this.id, "icon.jpg"); Response response = RestUtils.putContentToFile(ref, uploadedInputStream, body.getMediaType()); if (StringUtils.isEmpty(this.application.getIconUrl())) { this.application.setIconUrl("icon.jpg"); persist(); } return response; }
@PUT @Path("image.jpg") @Consumes(MediaType.MULTIPART_FORM_DATA) public Response putImage(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataBodyPart body) { try { SelfServiceMetaDataUtils.ensureDataXmlExists(this.id); } catch (IOException e) { throw new WebApplicationException(e); } RepositoryFileReference ref = new RepositoryFileReference(this.id, "image.jpg"); Response response = RestUtils.putContentToFile(ref, uploadedInputStream, body.getMediaType()); if (StringUtils.isEmpty(this.application.getImageUrl())) { this.application.setImageUrl("image.jpg"); persist(); } return response; }
public Response onPost(@FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("file") FormDataBodyPart body, @Context UriInfo uriInfo, String fileName) { // existence check not required as instantiation of the resource ensures that the object only exists if the resource exists FilesResource.LOGGER.debug("Beginning with file upload"); if (StringUtils.isEmpty(fileName)) { return Response.status(Status.BAD_REQUEST).build(); } RepositoryFileReference ref = this.fileName2fileRef(fileName, false); // TODO: instead of fixing the media type, we could overwrite the browser's mediatype by using some user configuration BufferedInputStream bis = new BufferedInputStream(uploadedInputStream); org.apache.tika.mime.MediaType mediaType = BackendUtils.getFixedMimeType(bis, fileName, org.apache.tika.mime.MediaType.parse(body.getMediaType().toString())); Response response = RestUtils.putContentToFile(ref, bis, mediaType); if (response.getStatus() == Status.INTERNAL_SERVER_ERROR.getStatusCode()) { return response; } try { BackendUtils.synchronizeReferences(RepositoryFactory.getRepository(), (ArtifactTemplateId) fileDir.getParent()); } catch (IOException e) { throw new WebApplicationException(e, Status.INTERNAL_SERVER_ERROR); } String URL = RestUtils.getAbsoluteURL(this.fileDir) + Util.URLencode(fileName); return Response.created(RestUtils.createURI(URL)).entity(this.getAllFileMetas()).build(); }
RestUtils.putContentToFile(iconRef, uploadedInputStream, body.getMediaType());
if (Arrays.binarySearch(Pictogram.ALLOWED_IMAGE_TYPES, uploadedImagePart.getMediaType().toString()) < 0) { errors.put("uploadedImage", "error.UploadWrongFileTypeOnlyImages"); } else { entity.setData(uploadedImage); entity.setMimeType(uploadedImagePart.getMediaType().toString()); entity.setFileName(uploadedImageDetail.getFileName());
@PUT @Consumes( {MediaType.MULTIPART_FORM_DATA}) @ApiOperation(value = "Resource currently works for BPMN4TOSCA plans only") public Response onPutFile( @FormDataParam("file") InputStream uploadedInputStream, @FormDataParam("file") FormDataContentDisposition fileDetail, @FormDataParam("file") FormDataBodyPart body ) { String fileName = fileDetail.getFileName(); RepositoryFileReference ref = new RepositoryFileReference(this.planId, fileName); RepositoryFileReference oldRef = this.getFileRef(); // if oldRef exists -> check for equality and afterwards overwrite the old content if (oldRef != null && !ref.equals(oldRef)) { // new filename sent RestUtils.delete(oldRef); PlansResource.setPlanModelReference(this.plan, this.planId, fileName); RestUtils.persist(this.res); } return RestUtils.putContentToFile(ref, uploadedInputStream, org.apache.tika.mime.MediaType.parse(body.getMediaType().toString())); }
entity.setMimeType(uploadedFilePart.getMediaType().toString()); if (entity.getFilename() == null) entity.setFilename(uploadedFileDetail.getFileName()); entity.setMimeType(uploadedFilePart.getMediaType().toString()); entity.setFilename(uploadedFileDetail.getFileName()); entity.setFileSize(new Long(uploadedFile.length));
RestUtils.putContentToFile(ref, uploadedInputStream, body.getMediaType());