Page tree

Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


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.

titleImage Size Not Supported

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.


Code Block
File file = new File("C:/Temp/test.doc");
FileResponse response = client.postFileToSpace(file, spaceId);
assert (!"".equals(response.getName()));
assert (appId.equals(response.getCreatedBy()));
Code Block
File photo = new File("C:/Temp/testPhoto.jpg");
FileResponse response = client.postFileToSpace(photo, spaceId, "50x50");
assert (!"".equals(response.getName()));
assert (appId.equals(response.getCreatedBy()))