Merge pull request #3400 from riadvice/fix-file-upload-extension
Unify uploaded presentation file naming across bigbluebutton-web
This commit is contained in:
commit
886f9617ac
@ -2089,7 +2089,7 @@ class ApiController {
|
||||
def presId = presDownloadService.generatePresentationId(presFilename)
|
||||
File uploadDir = presDownloadService.createPresentationDirectory(meetingId, presentationDir, presId)
|
||||
if (uploadDir != null) {
|
||||
def newFilename = presDownloadService.createNewFilename(presId, filenameExt)
|
||||
def newFilename = Util.createNewFilename(presId, filenameExt)
|
||||
def newFilePath = uploadDir.absolutePath + File.separatorChar + newFilename
|
||||
|
||||
if (presDownloadService.savePresentation(meetingId, newFilePath, address)) {
|
||||
|
@ -10,9 +10,9 @@ public final class Util {
|
||||
return DigestUtils.shaHex(name) + "-" + timestamp;
|
||||
}
|
||||
|
||||
public static String createNewFilename(String presId, String fileExt) {
|
||||
return presId + fileExt;
|
||||
}
|
||||
public static String createNewFilename(String presId, String fileExt) {
|
||||
return presId + "." + fileExt;
|
||||
}
|
||||
|
||||
public static File createPresentationDirectory(String meetingId, String presentationDir, String presentationId) {
|
||||
String meetingPath = presentationDir + File.separatorChar + meetingId + File.separatorChar + meetingId;
|
||||
|
@ -14,6 +14,7 @@ import org.apache.commons.httpclient.HttpStatus;
|
||||
import org.apache.commons.httpclient.methods.GetMethod;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.bigbluebutton.api.Util;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@ -65,7 +66,7 @@ public class PresentationUrlDownloadService {
|
||||
String filenameExt = FilenameUtils
|
||||
.getExtension(sourcePresentationFile.getName());
|
||||
String presId = generatePresentationId(presentationId);
|
||||
String newFilename = createNewFilename(presId, filenameExt);
|
||||
String newFilename = Util.createNewFilename(presId, filenameExt);
|
||||
|
||||
File uploadDir = createPresentationDirectory(destinationMeetingId,
|
||||
presentationDir, presId);
|
||||
@ -86,10 +87,6 @@ public class PresentationUrlDownloadService {
|
||||
return DigestUtils.shaHex(name) + "-" + timestamp;
|
||||
}
|
||||
|
||||
public String createNewFilename(String presId, String fileExt) {
|
||||
return presId + "." + fileExt;
|
||||
}
|
||||
|
||||
public File createPresentationDirectory(String meetingId,
|
||||
String presentationDir, String presentationId) {
|
||||
String meetingPath = presentationDir + File.separatorChar + meetingId
|
||||
|
@ -21,11 +21,13 @@ package org.bigbluebutton.presentation;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.bigbluebutton.api.messaging.MessagingConstants;
|
||||
import org.bigbluebutton.api.messaging.MessagingService;
|
||||
import org.bigbluebutton.presentation.ConversionUpdateMessage.MessageBuilder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
|
||||
public class SupportedDocumentFilter {
|
||||
@ -41,13 +43,15 @@ public class SupportedDocumentFilter {
|
||||
File presentationFile = pres.getUploadedFile();
|
||||
|
||||
/* Get file extension - Perhaps try to rely on a more accurate method than an extension type ? */
|
||||
int fileExtIndex = presentationFile.getName().lastIndexOf('.') + 1;
|
||||
String ext = presentationFile.getName().toLowerCase().substring(fileExtIndex);
|
||||
boolean supported = SupportedFileTypes.isFileSupported(ext);
|
||||
String extension = FilenameUtils.getExtension(presentationFile.getName());
|
||||
boolean supported = SupportedFileTypes.isFileSupported(extension);
|
||||
notifyProgressListener(supported, pres);
|
||||
if (supported) {
|
||||
log.info("Received supported file " + pres.getUploadedFile().getAbsolutePath());
|
||||
pres.setFileType(ext);
|
||||
log.info("Received supported file {}", pres.getUploadedFile().getAbsolutePath());
|
||||
pres.setFileType(extension);
|
||||
}
|
||||
else {
|
||||
log.warn("Received not supported file {}", pres.getUploadedFile().getAbsolutePath());
|
||||
}
|
||||
return supported;
|
||||
}
|
||||
@ -65,9 +69,9 @@ public class SupportedDocumentFilter {
|
||||
Gson gson= new Gson();
|
||||
String updateMsg=gson.toJson(builder.build().getMessage());
|
||||
log.debug("sending: "+updateMsg);
|
||||
messagingService.send(MessagingConstants.TO_PRESENTATION_CHANNEL, updateMsg);
|
||||
messagingService.send(MessagingConstants.TO_PRESENTATION_CHANNEL, updateMsg);
|
||||
} else {
|
||||
log.warn("MessagingService has not been set!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user