parent
b7c26a733d
commit
4053c19863
|
@ -15,7 +15,6 @@ import org.slf4j.LoggerFactory;
|
||||||
public class WorkspaceManager {
|
public class WorkspaceManager {
|
||||||
private static final Logger logger = LoggerFactory.getLogger(WorkspaceManager.class);
|
private static final Logger logger = LoggerFactory.getLogger(WorkspaceManager.class);
|
||||||
|
|
||||||
|
|
||||||
public String uploadFile(byte[] in, String name, String description) throws NlpHubException {
|
public String uploadFile(byte[] in, String name, String description) throws NlpHubException {
|
||||||
if (name == null || name.isEmpty()) {
|
if (name == null || name.isEmpty()) {
|
||||||
String error = "Error uploading the file, the filename is invalid: Null";
|
String error = "Error uploading the file, the filename is invalid: Null";
|
||||||
|
@ -27,20 +26,29 @@ public class WorkspaceManager {
|
||||||
FolderContainer rootContainer = shc.getWSRoot();
|
FolderContainer rootContainer = shc.getWSRoot();
|
||||||
InputStream inputStream = new ByteArrayInputStream(in);
|
InputStream inputStream = new ByteArrayInputStream(in);
|
||||||
|
|
||||||
|
FileContainer fileContainer;
|
||||||
try {
|
try {
|
||||||
FileContainer fileContainer = rootContainer.uploadFile(inputStream,
|
fileContainer = rootContainer.uploadFile(inputStream, name, description);
|
||||||
name,description);
|
|
||||||
String itemId=fileContainer.get().getId();
|
|
||||||
logger.debug("Item id uploaded: " +itemId );
|
|
||||||
URL url = shc.open(itemId).asFile().getPublicLink();
|
|
||||||
logger.debug("Item public link: " +url);
|
|
||||||
|
|
||||||
return url.toString();
|
|
||||||
} catch (StorageHubException e) {
|
} catch (StorageHubException e) {
|
||||||
String error = "Error uploading the file " + name+ " : " + e.getLocalizedMessage();
|
String error = "Error uploading the file " + name + " : " + e.getLocalizedMessage();
|
||||||
logger.error(error, e);
|
logger.error(error, e);
|
||||||
throw new NlpHubException(error, e);
|
throw new NlpHubException(error, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String itemId = fileContainer.get().getId();
|
||||||
|
logger.debug("Item id uploaded: " + itemId);
|
||||||
|
|
||||||
|
URL url;
|
||||||
|
try {
|
||||||
|
url = shc.open(itemId).asFile().getPublicLink();
|
||||||
|
} catch (StorageHubException e) {
|
||||||
|
String error = "Error retrieving the public link for the file " + name + " : " + e.getLocalizedMessage();
|
||||||
|
logger.error(error, e);
|
||||||
|
throw new NlpHubException(error, e);
|
||||||
|
}
|
||||||
|
logger.debug("Item public link: " + url);
|
||||||
|
|
||||||
|
return url.toString();
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue