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     * If the size cannot be determined value will be -1.
127     *
128     * @return the size of the file's content.
129     */
130    public long getSize() {
131        return this.size;
132    }
133
134    /**
135     * Sets the size of the file content used for monitoring the upload's progress.
136     * When the content is coming from a dynamic source - other thread reading value
137     * set size to -1 to tell SDK that file size cannot be determined. Usefull
138     * when encuntering problems with writing different size of bytes than assumed.
139     *
140     * @param size the size of the file's content.
141     * @return this FileUploadParams object for chaining.
142     */
143    public FileUploadParams setSize(long size) {
144        this.size = size;
145        return this;
146    }
147
148    /**
149     * Gets the ProgressListener that will be used for monitoring the upload's progress.
150     *
151     * @return the ProgressListener that will be used for monitoring the upload's progress.
152     */
153    public ProgressListener getProgressListener() {
154        return this.listener;
155    }
156
157    /**
158     * Sets the ProgressListener that will be used for monitoring the upload's progress.
159     *
160     * @param listener the listener that will be used for monitoring the upload's progress.
161     * @return this FileUploadParams object for chaining.
162     */
163    public FileUploadParams setProgressListener(ProgressListener listener) {
164        this.listener = listener;
165        return this;
166    }
167
168    /**
169     * Gets the file's SHA-1 hash.
170     *
171     * @return the file hash.
172     */
173    public String getSHA1() {
174        return this.sha1;
175    }
176
177    /**
178     * Set the SHA-1 hash of the file to ensure it is not corrupted during the upload.
179     *
180     * @param sha1 the SHA-1 hash of the file.
181     * @return this FileUploadParams for chaining.
182     */
183    public FileUploadParams setSHA1(String sha1) {
184        this.sha1 = sha1;
185        return this;
186    }
187
188    /**
189     * Gets the file's description set for uploading.
190     *
191     * @return the file description.
192     */
193    public String getDescription() {
194        return this.description;
195    }
196
197    /**
198     * Sets the file description during the file upload.
199     *
200     * @param description the description of the file.
201     * @return this FileUploadParams for chaining.
202     */
203    public FileUploadParams setDescription(String description) {
204        this.description = description;
205        return this;
206    }
207}