/** * Try to resume an already started upload. Before call this function, resuming must be * enabled using {@link #enableResuming(TusURLStore)}. This method will look up the URL for this * upload in the {@link TusURLStore} using the upload's fingerprint (see * {@link TusUpload#getFingerprint()}). After a successful lookup a HEAD request will be issued * to find the current offset without uploading the file, yet. * * @param upload The file for which an upload will be resumed * @return Use {@link TusUploader} to upload the remaining file's chunks. * @throws FingerprintNotFoundException Thrown if no matching fingerprint has been found in * {@link TusURLStore}. Use {@link #createUpload(TusUpload)} to create a new upload. * @throws ResumingNotEnabledException Throw if resuming has not been enabled using {@link * #enableResuming(TusURLStore)}. * @throws ProtocolException Thrown if the remote server sent an unexpected response, e.g. * wrong status codes or missing/invalid headers. * @throws IOException Thrown if an exception occurs while issuing the HTTP request. */ public TusUploader resumeUpload(@NotNull TusUpload upload) throws FingerprintNotFoundException, ResumingNotEnabledException, ProtocolException, IOException { if (!resumingEnabled) { throw new ResumingNotEnabledException(); } URL uploadURL = urlStore.get(upload.getFingerprint()); if (uploadURL == null) { throw new FingerprintNotFoundException(upload.getFingerprint()); } return beginOrResumeUploadFromURL(upload, uploadURL); }
@Test public void test() throws MalformedURLException { TusURLStore store = new TusURLMemoryStore(); URL url = new URL("https://master.tus.io/files/hello"); String fingerprint = "foo"; store.set(fingerprint, url); assertEquals(store.get(fingerprint), url); store.remove(fingerprint); assertEquals(store.get(fingerprint), null); } }