/** * Create converted ffmpeg payload * * @param object DigitalObject to store the payload * @param file File to be stored as payload * @return Payload new payload * @throws StorageException if there is a problem trying to store * @throws FileNotFoundException if the file provided does not exist */ public Payload createFfmpegPayload(DigitalObject object, File file) throws StorageException, FileNotFoundException { String name = file.getName(); Payload payload = StorageUtils.createOrUpdatePayload(object, name, new FileInputStream(file)); payload.setContentType(MimeTypeUtil.getMimeType(name)); payload.setLabel(name); return payload; }
/** * Create ffmpeg error payload * * @param object : DigitalObject to store the payload * @return Payload the error payload * @throws FileNotFoundException if the file provided does not exist * @throws UnsupportedEncodingException for encoding errors in the message */ public Payload createFfmpegErrorPayload(DigitalObject object) throws StorageException, FileNotFoundException, UnsupportedEncodingException { // Compile our error data JsonConfigHelper content = new JsonConfigHelper(); content.setJsonMap("/", errors); log.debug("\nErrors:\n{}", content.toString()); InputStream data = new ByteArrayInputStream(content.toString().getBytes("UTF-8")); // Write to the object Payload payload = StorageUtils.createOrUpdatePayload(object, ERROR_PAYLOAD, data); payload.setType(PayloadType.Error); payload.setContentType("application/json"); payload.setLabel("FFMPEG conversion errors"); return payload; }