io.micronaut.http.multipart.FileUpload Maven / Gradle / Ivy
The newest version!
/*
* Copyright 2017-2020 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.http.multipart;
import io.micronaut.core.annotation.Internal;
import io.micronaut.http.MediaType;
import java.util.Optional;
/**
* Represents a part of a {@link io.micronaut.http.MediaType#MULTIPART_FORM_DATA} request.
*
* @author Graeme Rocher
* @since 1.0
*/
@Internal
public interface FileUpload {
/**
* Gets the content type of this part.
*
* @return The content type of this part.
*/
Optional getContentType();
/**
* Gets the name of this part.
*
* @return The name of this part
*/
String getName();
/**
* Gets the name of this part.
*
* @return The name of this part
*/
String getFilename();
/**
* Returns the size of the part.
*
* @return The size of this part, in bytes.
*/
long getSize();
/**
* Returns the defined content length of the part.
*
* @return The content length of this part, in bytes.
*/
long getDefinedSize();
/**
* Returns whether the {@link FileUpload} has been fully uploaded or is in a partial state.
*
* @return True if the part is fully uploaded
*/
boolean isComplete();
/**
* Discards the contents of the file. This must be called
* if the file will not be read and has not already been read.
*
* Failure to either read or discard the file will result in
* memory leaks!
*
* @since 2.4.0
*/
default void discard() {
throw new UnsupportedOperationException("Discard not supported");
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy