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