public interface FilesQueryApi
Result
,
Testrun
). This file lets you create the stored files (which you must do
before using them in the other objects).
This api also has some convenience methods for creating and uploading the file all at once. Strictly speaking
you don't have to do it this way, but it is recommended.
The one field that is somewhat critical, is the mime type field of StoredFile
.
That file tells slick what kind of file you are using. So if you use the
create(com.slickqa.client.model.StoredFile)
method, make sure you include the mime type. You can
use Files.probeContentType(java.nio.file.Path)
.
SlickClient slick = SlickClientFactory.getSlickClient("http://localhost/slick/api"); StoredFile movie = slick.files().createAndUpload(Paths.get("results", "testMovie.mp4")); System.out.println(MessageFormat.format("You can download the movie at http://localhost/slick/api/files/{0}/content/{1}", movie.getId(), movie.getFileName()));
Modifier and Type | Method and Description |
---|---|
StoredFile |
create(StoredFile storedFile)
Create a new StoredFile in slick.
|
StoredFile |
createAndUpload(Path localPath)
Create a new StoredFile in slick, and upload the content from a local file path.
|
StoredFile |
createAndUpload(String filename,
String mimetype,
InputStream stream)
Create a new StoredFile in slick, and upload the content from an
InputStream . |
StoredFile create(StoredFile storedFile) throws SlickError
addChunk
method of
the FilesApi
).storedFile
- The meta-data about the file you want to add.SlickError
- If there was a problem talking to slick.StoredFile createAndUpload(Path localPath) throws SlickError
localPath
- The local path to open the file and upload it.SlickError
- if an IO Exception occurs or there is a problem talking with slick.StoredFile createAndUpload(String filename, String mimetype, InputStream stream) throws SlickError
InputStream
.filename
- The name of the file (used in creating the StoredFile
).mimetype
- The mime type of the file.stream
- The input stream to read from.StoredFile
saved by slick.SlickError
- if an error reading the steam occurs, or if any error occurs while creating the object or uploading the content.Copyright © 2015. All rights reserved.