Skip to content

Commit

Permalink
Restore FileUploadValidator.from method to avoid breaking changes
Browse files Browse the repository at this point in the history
  • Loading branch information
amanteaux committed Dec 14, 2023
1 parent 3781144 commit 84a4290
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import com.coreoz.plume.jersey.errors.WsError;
import com.coreoz.plume.jersey.errors.WsException;
import com.google.common.base.Strings;
import org.glassfish.jersey.media.multipart.FormDataBodyPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand Down Expand Up @@ -66,6 +67,22 @@ private FileUploadValidator(
}
}

/**
* Starts a new validation process using Jersey fields FormDataBodyPart and InputStream.
* See {@link #from(String, long, InputStream, FileMimeTypeDetector)} for streaming upload
* not relying on Jersey.
*/
public static FileUploadSizeValidator from(FormDataBodyPart fileMetadata, InputStream fileData,
FileMimeTypeDetector fileMimeTypeDetector) {
Validators.checkRequired(fileMetadata);
return from(
fileMetadata.getContentDisposition().getFileName(),
fileMetadata.getFormDataContentDisposition().getSize(),
fileData,
fileMimeTypeDetector
);
}

/**
* Starts a new validation process using Jersey fields FormDataBodyPart and InputStream
* @param fileName the file name
Expand Down

0 comments on commit 84a4290

Please sign in to comment.