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
019    /**
020     * Constructs a new FileUploadParams with default parameters.
021     */
022    public FileUploadParams() { }
023
024    /**
025     * Gets the content that will be uploaded to Box.
026     * @return an InputStream that reads the content to be uploaded to Box.
027     */
028    public InputStream getContent() {
029        return this.content;
030    }
031
032    /**
033     * Sets the content that will be uploaded to Box.
034     * @param  content an InputStream that reads from the content to be uploaded to Box.
035     * @return         this FileUploadParams object for chaining.
036     */
037    public FileUploadParams setContent(InputStream content) {
038        this.content = content;
039        return this;
040    }
041
042    /**
043     * @return content writer callback.
044     */
045    public UploadFileCallback getUploadFileCallback() {
046        return this.uploadFileCallback;
047    }
048
049    /**
050     * Sets the content writer callback.
051     *
052     * @param uploadFileCallback callback called when file upload starts.
053     * @return         this FileUploadParams object for chaining.
054     */
055    public FileUploadParams setUploadFileCallback(UploadFileCallback uploadFileCallback) {
056        this.uploadFileCallback = uploadFileCallback;
057        return this;
058    }
059
060    /**
061     * Gets the name that will be given to the uploaded file.
062     * @return the name that will be given to the uploaded file.
063     */
064    public String getName() {
065        return this.name;
066    }
067
068    /**
069     * Sets the name that will be given to the uploaded file.
070     * @param  name the name that will be given to the uploaded file.
071     * @return      this FileUploadParams object for chaining.
072     */
073    public FileUploadParams setName(String name) {
074        this.name = name;
075        return this;
076    }
077
078    /**
079     * Gets the content created date that will be given to the uploaded file.
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     * @param  created the content created date that will be given to the uploaded file.
089     * @return         this FileUploadParams object for chaining.
090     */
091    public FileUploadParams setCreated(Date created) {
092        this.created = created;
093        return this;
094    }
095
096    /**
097     * Gets the content modified date that will be given to the uploaded file.
098     * @return the content modified date that will be given to the uploaded file.
099     */
100    public Date getModified() {
101        return this.modified;
102    }
103
104    /**
105     * Sets the content modified date that will be given to the uploaded file.
106     * @param  modified the content modified date that will be given to the uploaded file.
107     * @return          this FileUploadParams object for chaining.
108     */
109    public FileUploadParams setModified(Date modified) {
110        this.modified = modified;
111        return this;
112    }
113
114    /**
115     * Gets the size of the file's content used for monitoring the upload's progress.
116     * @return the size of the file's content.
117     */
118    public long getSize() {
119        return this.size;
120    }
121
122    /**
123     * Sets the size of the file content used for monitoring the upload's progress.
124     * @param  size the size of the file's content.
125     * @return      this FileUploadParams object for chaining.
126     */
127    public FileUploadParams setSize(long size) {
128        this.size = size;
129        return this;
130    }
131
132    /**
133     * Gets the ProgressListener that will be used for monitoring the upload's progress.
134     * @return the ProgressListener that will be used for monitoring the upload's progress.
135     */
136    public ProgressListener getProgressListener() {
137        return this.listener;
138    }
139
140    /**
141     * Sets the ProgressListener that will be used for monitoring the upload's progress.
142     * @param  listener the listener that will be used for monitoring the upload's progress.
143     * @return          this FileUploadParams object for chaining.
144     */
145    public FileUploadParams setProgressListener(ProgressListener listener) {
146        this.listener = listener;
147        return this;
148    }
149
150    /**
151     * Set the SHA-1 hash of the file to ensure it is not corrupted during the upload.
152     * @param sha1 the SHA-1 hash of the file.
153     * @return     this FileUploadParams for chaining.
154     */
155    public FileUploadParams setSHA1(String sha1) {
156        this.sha1 = sha1;
157        return this;
158    }
159
160    /**
161     * Gets the file's SHA-1 hash.
162     * @return the file hash.
163     */
164    public String getSHA1() {
165        return this.sha1;
166    }
167}