DocumentStore store = DocumentStore.instance();
String id = store.newId();
DocumentType type = new DocumentType("", resource.getContentType());
DocumentData documentData = new DownloadableDocumentData(baseName, type, resource.getData());
documentData.setFilename(resource.getFileName());
documentData.setDisposition(resource.getDisposition());
String url = store.preferredUrlForContent(resource.getFileName(), type.getExtension(), id);
url = Manager.instance().encodeConversationId(url, viewId);
store.saveData(id, documentData);
return url;