73 lines
2.0 KiB
Java
73 lines
2.0 KiB
Java
/* */ package kong.unirest.cosmetics;
|
|
/* */
|
|
/* */ import java.io.File;
|
|
/* */ import java.io.IOException;
|
|
/* */ import java.io.InputStream;
|
|
/* */ import java.nio.file.CopyOption;
|
|
/* */ import java.nio.file.Files;
|
|
/* */ import java.nio.file.Path;
|
|
/* */ import java.nio.file.Paths;
|
|
/* */ import java.util.Optional;
|
|
/* */ import java.util.function.Consumer;
|
|
/* */ import java.util.function.Function;
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */
|
|
/* */ public class FileResponse
|
|
/* */ extends BaseResponse<File>
|
|
/* */ {
|
|
/* */ private File body;
|
|
/* */
|
|
/* */ public FileResponse(RawResponse r, String path, ProgressMonitor downloadMonitor, CopyOption... copyOptions) {
|
|
/* 40 */ super(r);
|
|
/* */ try {
|
|
/* 42 */ Path target = Paths.get(path, new String[0]);
|
|
/* 43 */ InputStream content = getContent(r, downloadMonitor, target);
|
|
/* 44 */ Files.copy(content, target, copyOptions);
|
|
/* 45 */ this.body = target.toFile();
|
|
/* 46 */ } catch (IOException e) {
|
|
/* 47 */ throw new UnirestException(e);
|
|
/* */ }
|
|
/* */ }
|
|
/* */
|
|
/* */ private InputStream getContent(RawResponse r, ProgressMonitor downloadMonitor, Path target) {
|
|
/* 52 */ if (downloadMonitor == null) {
|
|
/* 53 */ return r.getContent();
|
|
/* */ }
|
|
/* 55 */ return new MonitoringInputStream(r.getContent(), downloadMonitor, target, r);
|
|
/* */ }
|
|
/* */
|
|
/* */
|
|
/* */ public File getBody() {
|
|
/* 60 */ return this.body;
|
|
/* */ }
|
|
/* */
|
|
/* */
|
|
/* */ protected String getRawBody() {
|
|
/* 65 */ return null;
|
|
/* */ }
|
|
/* */ }
|
|
|
|
|
|
/* Location: C:\Users\Xiao\Downloads\MinehutCosmetics.jar!\kon\\unirest\cosmetics\FileResponse.class
|
|
* Java compiler version: 11 (55.0)
|
|
* JD-Core Version: 1.1.3
|
|
*/ |