2011-06-18 02:01:37 +08:00
<html>
2011-09-04 22:29:26 +08:00
<head><title>Join & Upload Presentation</title></head></p> <p>
2011-06-18 02:01:37 +08:00
<body>
<%@ include file="bbb_api.jsp"%>
<%@ include file="demo_header.jsp"%>
2011-09-04 22:29:26 +08:00
<h2>Join & Upload Presentation</h2>
2011-09-04 02:32:32 +08:00
<form action="demo7.jsp" method="post" enctype="multipart/form-data" name="form1" id="form1">
2011-06-18 02:01:37 +08:00
<table cellpadding="5" cellspacing="5" style="width: 400px;">
<tbody>
<tr>
<td> </td>
2011-09-04 02:32:32 +08:00
<td style="text-align: right;">Full Name:</td>
2011-06-18 02:01:37 +08:00
<td style="width: 5px;"> </td>
<td style="text-align: left"><input type="text"
name="username" />
</td>
</tr>
<tr>
<td> </td>
2011-09-04 02:32:32 +08:00
<td style="text-align: left">Upload File:</td>
2011-06-18 02:01:37 +08:00
<td style="width: 5px;"> </td>
<td style="text-align: left"><input type="file"
2011-09-04 02:32:32 +08:00
name="filename" /><!-- <input type="submit" / -->
2011-06-18 02:01:37 +08:00
</td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td><input type="submit" value="Join" />
</td>
</tr>
</tbody>
</table>
<INPUT TYPE=hidden NAME=action VALUE="create">
</form>
</body>
</html>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.io.File" %>
<%@ page import="org.apache.commons.fileupload.servlet.ServletFileUpload"%>
<%@ page import="org.apache.commons.fileupload.disk.DiskFileItemFactory"%>
<%@ page import="org.apache.commons.fileupload.*"%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@page import="sun.security.provider.SHA"%>
<%@page import="org.apache.commons.codec.binary.Base64"%>
<%@page import="java.security.MessageDigest"%>
<%
String uname="";
boolean isMultipart = ServletFileUpload.isMultipartContent(request);
if (!isMultipart) {
}
else {
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload upload = new ServletFileUpload(factory);
List<FileItem> items = null;
try {
items = upload.parseRequest(request);
} catch (FileUploadException e) {
e.printStackTrace();
}
out.print(items.size());
Iterator<FileItem> itr = items.iterator();
while (itr.hasNext()) {
FileItem item = (FileItem) itr.next();
String xml = null;
2011-09-04 23:40:19 +08:00
String url = BigBlueButtonURL.replace("bigbluebutton/","demo/");
String preUploadPDF = "<?xml version='1.0' encoding='UTF-8'?><modules><module name='presentation'><document url='"+url+"pdfs/sample.pdf'/></module></modules>";
2011-09-04 02:32:32 +08:00
xml = preUploadPDF;
2011-06-18 02:01:37 +08:00
if (item.isFormField())
{
String name = item.getFieldName();
String value = item.getString();
if(name.equals("username"))
{
uname=value;
}
} else {
try {
String itemName = item.getName();
2011-09-04 02:32:32 +08:00
if(itemName!=""){
2011-06-18 02:01:37 +08:00
byte[] b = item.get();
String encoded = Base64.encodeBase64String(b);
2011-09-04 02:32:32 +08:00
xml = "<?xml version='1.0' encoding='UTF-8'?><modules><module name=\"presentation\"><document name=\""+itemName+"\">"+encoded+"\"</document></module></modules>";
2011-06-18 02:01:37 +08:00
}
} catch (Exception e) {
e.printStackTrace();
}
2011-09-05 06:27:19 +08:00
String welcome = "<br>Welcome to <b>%%CONFNAME%%</b>!<br><br>To understand how BigBlueButton works see our <a href=\"event:http://www.bigbluebutton.org/content/videos\"><u>tutorial videos</u></a>.<br><br>To join the audio bridge click the headset icon (upper-left hand corner). <b>Please use a headset to avoid causing echo for others.</b>";
String welcomeMsg = "The uploaded presentation will appear in moment.<br>" + welcome;
2011-06-18 02:01:37 +08:00
2011-09-05 06:27:19 +08:00
String joinURL = getJoinURLXML(uname, "Join and Upload example", welcomeMsg, xml );
2011-06-18 02:01:37 +08:00
if (joinURL.startsWith("http://")) {
%>
<script language="javascript" type="text/javascript">
window.location.href="<%=joinURL%>";
</script>
<%
} else {
%>
Error: getJoinURL() failed
<p />
<%=joinURL %>
<%
}
}
}
}
%>
2011-09-04 23:19:37 +08:00
<%@ include file="demo_footer.jsp"%>
</body>
</html>