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    /**
027     * Gets the content that will be uploaded to Box.
028     *
029     * @return an InputStream that reads the content to be uploaded to Box.
030     */
031    public InputStream getContent() {
032        return this.content;
033    }
034
035    /**
036     * Sets the content that will be uploaded to Box.
037     *
038     * @param content an InputStream that reads from the content to be uploaded to Box.
039     * @return this FileUploadParams object for chaining.
040     */
041    public FileUploadParams setContent(InputStream content) {
042        this.content = content;
043        return this;
044    }
045
046    /**
047     * @return content writer callback.
048     */
049    public UploadFileCallback getUploadFileCallback() {
050        return this.uploadFileCallback;
051    }
052
053    /**
054     * Sets the content writer callback.
055     *
056     * @param uploadFileCallback callback called when file upload starts.
057     * @return this FileUploadParams object for chaining.
058     */
059    public FileUploadParams setUploadFileCallback(UploadFileCallback uploadFileCallback) {
060        this.uploadFileCallback = uploadFileCallback;
061        return this;
062    }
063
064    /**
065     * Gets the name that will be given to the uploaded file.
066     *
067     * @return the name that will be given to the uploaded file.
068     */
069    public String getName() {
070        return this.name;
071    }
072
073    /**
074     * Sets the name that will be given to the uploaded file.
075     *
076     * @param name the name that will be given to the uploaded file.
077     * @return this FileUploadParams object for chaining.
078     */
079    public FileUploadParams setName(String name) {
080        this.name = name;
081        return this;
082    }
083
084    /**
085     * Gets the content created date that will be given to the uploaded file.
086     *
087     * @return the content created date that will be given to the uploaded file.
088     */
089    public Date getCreated() {
090        return this.created;
091    }
092
093    /**
094     * Sets the content created date that will be given to the uploaded file.
095     *
096     * @param created the content created date that will be given to the uploaded file.
097     * @return this FileUploadParams object for chaining.
098     */
099    public FileUploadParams setCreated(Date created) {
100        this.created = created;
101        return this;
102    }
103
104    /**
105     * Gets the content modified date that will be given to the uploaded file.
106     *
107     * @return the content modified date that will be given to the uploaded file.
108     */
109    public Date getModified() {
110        return this.modified;
111    }
112
113    /**
114     * Sets the content modified date that will be given to the uploaded file.
115     *
116     * @param modified the content modified date that will be given to the uploaded file.
117     * @return this FileUploadParams object for chaining.
118     */
119    public FileUploadParams setModified(Date modified) {
120        this.modified = modified;
121        return this;
122    }
123
124    /**
125     * Gets the size of the file's content used for monitoring the upload's progress.
126     *
127     * @return the size of the file's content.
128     */
129    public long getSize() {
130        return this.size;
131    }
132
133    /**
134     * Sets the size of the file content used for monitoring the upload's progress.
135     *
136     * @param size the size of the file's content.
137     * @return this FileUploadParams object for chaining.
138     */
139    public FileUploadParams setSize(long size) {
140        this.size = size;
141        return this;
142    }
143
144    /**
145     * Gets the ProgressListener that will be used for monitoring the upload's progress.
146     *
147     * @return the ProgressListener that will be used for monitoring the upload's progress.
148     */
149    public ProgressListener getProgressListener() {
150        return this.listener;
151    }
152
153    /**
154     * Sets the ProgressListener that will be used for monitoring the upload's progress.
155     *
156     * @param listener the listener that will be used for monitoring the upload's progress.
157     * @return this FileUploadParams object for chaining.
158     */
159    public FileUploadParams setProgressListener(ProgressListener listener) {
160        this.listener = listener;
161        return this;
162    }
163
164    /**
165     * Gets the file's SHA-1 hash.
166     *
167     * @return the file hash.
168     */
169    public String getSHA1() {
170        return this.sha1;
171    }
172
173    /**
174     * Set the SHA-1 hash of the file to ensure it is not corrupted during the upload.
175     *
176     * @param sha1 the SHA-1 hash of the file.
177     * @return this FileUploadParams for chaining.
178     */
179    public FileUploadParams setSHA1(String sha1) {
180        this.sha1 = sha1;
181        return this;
182    }
183
184    /**
185     * Gets the file's description set for uploading.
186     *
187     * @return the file description.
188     */
189    public String getDescription() {
190        return this.description;
191    }
192
193    /**
194     * Sets the file description during the file upload.
195     *
196     * @param description the description of the file.
197     * @return this FileUploadParams for chaining.
198     */
199    public FileUploadParams setDescription(String description) {
200        this.description = description;
201        return this;
202    }
203}