001/*
002 * Copyright 2002-2017 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.http.codec.multipart;
018
019import reactor.core.publisher.Flux;
020
021import org.springframework.core.io.buffer.DataBuffer;
022import org.springframework.http.HttpHeaders;
023
024/**
025 * Representation for a part in a "multipart/form-data" request.
026 *
027 * <p>The origin of a multipart request may be a browser form in which case each
028 * part is either a {@link FormFieldPart} or a {@link FilePart}.
029 *
030 * <p>Multipart requests may also be used outside of a browser for data of any
031 * content type (e.g. JSON, PDF, etc).
032 *
033 * @author Sebastien Deleuze
034 * @author Rossen Stoyanchev
035 * @since 5.0
036 * @see <a href="https://tools.ietf.org/html/rfc7578">RFC 7578 (multipart/form-data)</a>
037 * @see <a href="https://tools.ietf.org/html/rfc2183">RFC 2183 (Content-Disposition)</a>
038 * @see <a href="https://www.w3.org/TR/html5/forms.html#multipart-form-data">HTML5 (multipart forms)</a>
039 */
040public interface Part {
041
042        /**
043         * Return the name of the part in the multipart form.
044         * @return the name of the part, never {@code null} or empty
045         */
046        String name();
047
048        /**
049         * Return the headers associated with the part.
050         */
051        HttpHeaders headers();
052
053        /**
054         * Return the content for this part.
055         * <p>Note that for a {@link FormFieldPart} the content may be accessed
056         * more easily via {@link FormFieldPart#value()}.
057         */
058        Flux<DataBuffer> content();
059
060}