001package com.box.sdk; 002 003import java.io.InputStream; 004import java.util.Date; 005 006/** 007 * Contains parameters for configuring an upload to Box. 008 */ 009public class FileUploadParams { 010 private InputStream content; 011 private UploadFileCallback uploadFileCallback; 012 private String name; 013 private Date created; 014 private Date modified; 015 private long size; 016 private ProgressListener listener; 017 private String sha1; 018 private String description; 019 020 /** 021 * Constructs a new FileUploadParams with default parameters. 022 */ 023 public FileUploadParams() { } 024 025 /** 026 * Gets the content that will be uploaded to Box. 027 * @return an InputStream that reads the content to be uploaded to Box. 028 */ 029 public InputStream getContent() { 030 return this.content; 031 } 032 033 /** 034 * Sets the content that will be uploaded to Box. 035 * @param content an InputStream that reads from the content to be uploaded to Box. 036 * @return this FileUploadParams object for chaining. 037 */ 038 public FileUploadParams setContent(InputStream content) { 039 this.content = content; 040 return this; 041 } 042 043 /** 044 * @return content writer callback. 045 */ 046 public UploadFileCallback getUploadFileCallback() { 047 return this.uploadFileCallback; 048 } 049 050 /** 051 * Sets the content writer callback. 052 * 053 * @param uploadFileCallback callback called when file upload starts. 054 * @return this FileUploadParams object for chaining. 055 */ 056 public FileUploadParams setUploadFileCallback(UploadFileCallback uploadFileCallback) { 057 this.uploadFileCallback = uploadFileCallback; 058 return this; 059 } 060 061 /** 062 * Gets the name that will be given to the uploaded file. 063 * @return the name that will be given to the uploaded file. 064 */ 065 public String getName() { 066 return this.name; 067 } 068 069 /** 070 * Sets the name that will be given to the uploaded file. 071 * @param name the name that will be given to the uploaded file. 072 * @return this FileUploadParams object for chaining. 073 */ 074 public FileUploadParams setName(String name) { 075 this.name = name; 076 return this; 077 } 078 079 /** 080 * Gets the content created date that will be given to the uploaded file. 081 * @return the content created date that will be given to the uploaded file. 082 */ 083 public Date getCreated() { 084 return this.created; 085 } 086 087 /** 088 * Sets the content created date that will be given to the uploaded file. 089 * @param created the content created date that will be given to the uploaded file. 090 * @return this FileUploadParams object for chaining. 091 */ 092 public FileUploadParams setCreated(Date created) { 093 this.created = created; 094 return this; 095 } 096 097 /** 098 * Gets the content modified date that will be given to the uploaded file. 099 * @return the content modified date that will be given to the uploaded file. 100 */ 101 public Date getModified() { 102 return this.modified; 103 } 104 105 /** 106 * Sets the content modified date that will be given to the uploaded file. 107 * @param modified the content modified date that will be given to the uploaded file. 108 * @return this FileUploadParams object for chaining. 109 */ 110 public FileUploadParams setModified(Date modified) { 111 this.modified = modified; 112 return this; 113 } 114 115 /** 116 * Gets the size of the file's content used for monitoring the upload's progress. 117 * @return the size of the file's content. 118 */ 119 public long getSize() { 120 return this.size; 121 } 122 123 /** 124 * Sets the size of the file content used for monitoring the upload's progress. 125 * @param size the size of the file's content. 126 * @return this FileUploadParams object for chaining. 127 */ 128 public FileUploadParams setSize(long size) { 129 this.size = size; 130 return this; 131 } 132 133 /** 134 * Gets the ProgressListener that will be used for monitoring the upload's progress. 135 * @return the ProgressListener that will be used for monitoring the upload's progress. 136 */ 137 public ProgressListener getProgressListener() { 138 return this.listener; 139 } 140 141 /** 142 * Sets the ProgressListener that will be used for monitoring the upload's progress. 143 * @param listener the listener that will be used for monitoring the upload's progress. 144 * @return this FileUploadParams object for chaining. 145 */ 146 public FileUploadParams setProgressListener(ProgressListener listener) { 147 this.listener = listener; 148 return this; 149 } 150 151 /** 152 * Set the SHA-1 hash of the file to ensure it is not corrupted during the upload. 153 * @param sha1 the SHA-1 hash of the file. 154 * @return this FileUploadParams for chaining. 155 */ 156 public FileUploadParams setSHA1(String sha1) { 157 this.sha1 = sha1; 158 return this; 159 } 160 161 /** 162 * Gets the file's SHA-1 hash. 163 * @return the file hash. 164 */ 165 public String getSHA1() { 166 return this.sha1; 167 } 168 169 /** 170 * Gets the file's description set for uploading. 171 * @return the file description. 172 */ 173 public String getDescription() { 174 return this.description; 175 } 176 177 /** 178 * Sets the file description during the file upload. 179 * @param description the description of the file. 180 * @return this FileUploadParams for chaining. 181 */ 182 public FileUploadParams setDescription(String description) { 183 this.description = description; 184 return this; 185 } 186}