@@ -186,15 +186,36 @@ public TusUploader createUpload(@NotNull TusUpload upload) throws ProtocolExcept
186186 * @throws IOException Thrown if an exception occurs while issuing the HTTP request.
187187 */
188188 public TusUploader resumeUpload (@ NotNull TusUpload upload ) throws FingerprintNotFoundException , ResumingNotEnabledException , ProtocolException , IOException {
189- if (!resumingEnabled ) {
189+ if (!resumingEnabled ) {
190190 throw new ResumingNotEnabledException ();
191191 }
192192
193193 URL uploadURL = urlStore .get (upload .getFingerprint ());
194- if (uploadURL == null ) {
194+ if (uploadURL == null ) {
195195 throw new FingerprintNotFoundException (upload .getFingerprint ());
196196 }
197197
198+ return beginOrResumeUploadFromURL (upload , uploadURL );
199+ }
200+
201+ /**
202+ * Begin an upload or alternatively resume it if the upload has already been started before. In contrast to
203+ * {@link #createUpload(TusUpload)} and {@link #resumeOrCreateUpload(TusUpload)} this method will not create a new
204+ * upload. The user must obtain the upload location URL on their own as this method will not send the POST request
205+ * which is normally used to create a new upload.
206+ * Therefore, this method is only useful if you are uploading to a service which takes care of creating the tus
207+ * upload for yourself. One example of such a service is the Vimeo API.
208+ * When called a HEAD request will be issued to find the current offset without uploading the file, yet.
209+ * The uploading can be started by using the returned {@link TusUploader} object.
210+ *
211+ * @param upload The file for which an upload will be resumed
212+ * @param uploadURL The upload location URL at which has already been created and this file should be uploaded to.
213+ * @return Use {@link TusUploader} to upload the remaining file's chunks.
214+ * @throws ProtocolException Thrown if the remote server sent an unexpected response, e.g.
215+ * wrong status codes or missing/invalid headers.
216+ * @throws IOException Thrown if an exception occurs while issuing the HTTP request.
217+ */
218+ public TusUploader beginOrResumeUploadFromURL (@ NotNull TusUpload upload , @ NotNull URL uploadURL ) throws ProtocolException , IOException {
198219 HttpURLConnection connection = (HttpURLConnection ) uploadURL .openConnection ();
199220 connection .setRequestMethod ("HEAD" );
200221 prepareConnection (connection );
0 commit comments