The org.opencode4workspace.endpoints.FilePostToSpaceEndpoint is used to post a file to a Space and retrieve a FileResponse object corresponding to a successful posting.
If the posting is successful, a FileResponse object is returned comprising the String id of the file, the String name of the file, the int size of the file in bytes, a Map of URLs for the file (metadata, no-redirect download, and redirect download), the Long created timestamp, the String id of the creator and the String contentType of the file.
Note: Posting image sizes is not currently supported. It has not been possible to work out how to add the "dim" parameter's content to the MultipartEntityBuilder in a way that is accepted by Watson Workspace. If you have experience of Apache MultipartEntityBuilder and are willing to take a look, please contact Paul Withers.
File file = new File("C:/Temp/test.doc"); FileResponse response = client.postFileToSpace(file, spaceId); assert (!"".equals(response.getName())); assert (appId.equals(response.getCreatedBy()));
File photo = new File("C:/Temp/testPhoto.jpg"); FileResponse response = client.postFileToSpace(photo, spaceId, "50x50"); assert (!"".equals(response.getName())); assert (appId.equals(response.getCreatedBy()))