@Override protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { return IOUtils.getStringFromStream(inputMessage.getBody()); }
@Override protected String readInternal(Class<? extends String> clazz, HttpInputMessage inputMessage) throws IOException, HttpMessageNotReadableException { return IOUtils.getStringFromStream(inputMessage.getBody()); }
/** * Handles an upload using the EXTERNAL method. * * @param request * @throws IOException */ public static File handleEXTERNALUpload(Request request) throws IOException { //get the URL for this file to upload final InputStream inStream=request.getEntity().getStream(); final String stringURL=IOUtils.getStringFromStream(inStream); final URL fileURL=new URL(stringURL); final File inputFile= IOUtils.URLToFile(fileURL); if(inputFile!=null && inputFile.exists() && inputFile.canRead()) { return inputFile; } return null; }
/** * Convert the input from the provided {@link Reader} into a {@link String}. * * @param src the {@link StreamSource} to copy from. * @return a {@link String} that contains the content of the provided {@link Reader}. * @throws IOException in case something bad happens. */ public static String getStringFromStreamSource(StreamSource src) throws IOException { inputNotNull(src); InputStream inputStream = src.getInputStream(); if (inputStream != null) { return getStringFromStream(inputStream); } else { final Reader r = src.getReader(); return getStringFromReader(r); } }
/** * Convert the input from the provided {@link Reader} into a {@link String}. * * @param inputStream the {@link Reader} to copy from. * @return a {@link String} that contains the content of the provided {@link Reader}. * @throws IOException in case something bad happens. */ public static String getStringFromStreamSource(StreamSource src) throws IOException { inputNotNull(src); InputStream inputStream = src.getInputStream(); if(inputStream != null) { return getStringFromStream(inputStream); }else { final Reader r = src.getReader(); return getStringFromReader(r); } }
/** * Handles an upload using the EXTERNAL method. * * @param request * @throws IOException */ public static org.geoserver.platform.resource.Resource handleEXTERNALUpload( HttpServletRequest request) throws IOException { // get the URL for this file to upload final String stringURL; File inputFile; try (InputStream inStream = request.getInputStream()) { stringURL = IOUtils.getStringFromStream(inStream); inputFile = new File(stringURL); if (!inputFile.exists()) { URL fileURL = new URL(stringURL); inputFile = IOUtils.URLToFile(fileURL); } } if (inputFile == null || !inputFile.exists()) { throw new RestException( "Failed to locate the input file " + stringURL, HttpStatus.BAD_REQUEST); } else if (!inputFile.canRead()) { throw new RestException( "Input file is not readable, check filesystem permissions: " + stringURL, HttpStatus.BAD_REQUEST); } return Files.asResource(inputFile); }
final String stringURL=IOUtils.getStringFromStream(inStream); final URL fileURL=new URL(stringURL);
final String stringURL = IOUtils.getStringFromStream(inStream); final URL fileURL = new URL(stringURL);