001/* 002 * Copyright 2002-2018 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 java.io.File; 020import java.nio.file.Path; 021 022import reactor.core.publisher.Mono; 023 024/** 025 * Specialization of {@link Part} that represents an uploaded file received in 026 * a multipart request. 027 * 028 * @author Rossen Stoyanchev 029 * @author Juergen Hoeller 030 * @since 5.0 031 */ 032public interface FilePart extends Part { 033 034 /** 035 * Return the original filename in the client's filesystem. 036 */ 037 String filename(); 038 039 /** 040 * Convenience method to copy the content of the file in this part to the 041 * given destination file. If the destination file already exists, it will 042 * be truncated first. 043 * <p>The default implementation delegates to {@link #transferTo(Path)}. 044 * @param dest the target file 045 * @return completion {@code Mono} with the result of the file transfer, 046 * possibly {@link IllegalStateException} if the part isn't a file 047 * @see #transferTo(Path) 048 */ 049 default Mono<Void> transferTo(File dest) { 050 return transferTo(dest.toPath()); 051 } 052 053 /** 054 * Convenience method to copy the content of the file in this part to the 055 * given destination file. If the destination file already exists, it will 056 * be truncated first. 057 * @param dest the target file 058 * @return completion {@code Mono} with the result of the file transfer, 059 * possibly {@link IllegalStateException} if the part isn't a file 060 * @since 5.1 061 * @see #transferTo(File) 062 */ 063 Mono<Void> transferTo(Path dest); 064 065}