Storage upload calls changed
git-svn-id: https://svn.research-infrastructures.eu/d4science/gcube/trunk/portlets/user/share-updates@122384 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
636c42d7aa
commit
e4f5ed7702
|
@ -40,5 +40,4 @@ public class Placeholder extends FlowPanel {
|
|||
add((Widget)atPrev);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -315,6 +315,7 @@ public class ShareUpdateForm extends Composite {
|
|||
up.setVisible(false);
|
||||
fileBrowse(up.getElement());
|
||||
uploadProgress.setVisible(true);
|
||||
attachButton.setEnabled(false);
|
||||
|
||||
}
|
||||
|
||||
|
@ -498,6 +499,8 @@ public class ShareUpdateForm extends Composite {
|
|||
@Override
|
||||
public void onSuccess(ClientFeed feed) {
|
||||
|
||||
//GWT.log("Saved feed looks like " + feed.toString());
|
||||
|
||||
submitButton.setEnabled(true);
|
||||
shareTextArea.setEnabled(true);
|
||||
shareTextArea.setText(SHARE_UPDATE_TEXT);
|
||||
|
@ -668,6 +671,9 @@ public class ShareUpdateForm extends Composite {
|
|||
|
||||
// enable anyway the button
|
||||
submitButton.setEnabled(true);
|
||||
|
||||
// enable attach button
|
||||
attachButton.setEnabled(true);
|
||||
}
|
||||
|
||||
// it returns a LinkPreview (for compatibility with old code)
|
||||
|
@ -690,6 +696,9 @@ public class ShareUpdateForm extends Composite {
|
|||
|
||||
addPreviewAttachment(result, atPrev);
|
||||
submitButton.setEnabled(true);
|
||||
|
||||
// enable attach button
|
||||
attachButton.setEnabled(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
firstAttachmentDescription = "",
|
||||
firstAttachmentFormat = "",
|
||||
firstAttachmentDownloadUrl = "",
|
||||
firstAttachmenturlThumbnail = "null";
|
||||
firstAttachmenturlThumbnail = "";
|
||||
|
||||
if(uploadedFiles.size() > 0){
|
||||
|
||||
|
@ -343,6 +343,7 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
attachments = new ArrayList<>();
|
||||
|
||||
// starting from 1
|
||||
for (int i = 1; i < uploadedFiles.size(); i++){
|
||||
UploadedFile file = uploadedFiles.get(i);
|
||||
|
||||
|
@ -351,9 +352,9 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
file.getDownloadUrl(),
|
||||
file.getFileName(),
|
||||
file.getDescription(),
|
||||
file.getThumbnailUrl() == null ? "null" : file.getThumbnailUrl(),
|
||||
file.getThumbnailUrl(),
|
||||
file.getFormat())
|
||||
);
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -542,20 +543,25 @@ public class ShareUpdateServiceImpl extends RemoteServiceServlet implements Shar
|
|||
|
||||
String httpURL = "";
|
||||
String smpURI = "";
|
||||
String mimeType = null;
|
||||
if (isWithinPortal()) {
|
||||
//get the url to show, before actually uploading it
|
||||
smpURI = storageClient.getUrl(true).RFile(remoteFilePath); //"http://ciccio.com";
|
||||
//smpURI = storageClient.getUrl(true).RFile(remoteFilePath); //"http://ciccio.com";
|
||||
smpURI = storageClient.getHttpUrl(true).RFile(remoteFilePath);
|
||||
|
||||
//The storage uploader Thread starts here asyncronously
|
||||
Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath));
|
||||
//The storage uploader Thread starts here asyncronouslyù
|
||||
try {
|
||||
mimeType = FilePreviewer.getMimeType(new File(fileabsolutePathOnServer), fileName);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Thread thread = new Thread(new UploadToStorageThread(storageClient, fileName, fileabsolutePathOnServer, remoteFilePath, mimeType));
|
||||
thread.start();
|
||||
}
|
||||
|
||||
try {
|
||||
String mimeType = FilePreviewer.getMimeType(new File(fileabsolutePathOnServer), fileName);
|
||||
UriResolverReaderParameter resolver = new UriResolverReaderParameter();
|
||||
//get the url to show (though it could not be ready for download at this stage)
|
||||
httpURL = resolver.resolveAsUriRequest(smpURI, fileName, mimeType, true);
|
||||
httpURL = smpURI;
|
||||
|
||||
switch (mimeType) {
|
||||
case "application/pdf":
|
||||
|
|
|
@ -26,22 +26,27 @@ public class UploadToStorageThread implements Runnable {
|
|||
private String fileabsolutePathOnServer;
|
||||
|
||||
private IClient sClient;
|
||||
|
||||
// type of file
|
||||
private String mimeType;
|
||||
/**
|
||||
*
|
||||
* @param sClient the instance of the storage client
|
||||
* @param mimeType
|
||||
* @param fileToUpload the absolute path of the file
|
||||
*/
|
||||
public UploadToStorageThread(IClient sClient, String fileName, String fileabsolutePathOnServer, String remoteFilePath) {
|
||||
public UploadToStorageThread(IClient sClient, String fileName, String fileabsolutePathOnServer, String remoteFilePath, String mimeType) {
|
||||
super();
|
||||
this.sClient = sClient;
|
||||
this.remoteFilePath = remoteFilePath;
|
||||
this.fileName = fileName;
|
||||
this.fileabsolutePathOnServer = fileabsolutePathOnServer;
|
||||
this.mimeType = mimeType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String theID = sClient.put(true).LFile(fileabsolutePathOnServer).RFile(remoteFilePath);
|
||||
String theID = sClient.put(true, mimeType).LFile(fileabsolutePathOnServer).RFile(remoteFilePath);
|
||||
_log.debug("Uploaded " + fileName + " - Returned Storage id=" + theID);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue