FileCap Plugin Interface

The FileCap plugin interface can be accessed by applications using the API key.

The plugin interface consists of 3 pages:

  1. checkFile.jsp
    The checkFile page has the ability to verify before sending if a file is allowed to be send. Next to that checkFile.jsp can verify if all files are received correctly after sending and can be used to check if a FileCap id is used already.
  2. invite.jsp
    The invite page gives the ability to send invites to external users.
  3. process_upload.jsp
    process upload can be used to upload files to the FileCap server.

checkFile.jsp

Check if a sender is permitted to send a file

checkFile.jsp accepts the following GET/POST parameters for checking if a user is permitted to send a file:

  1. sender – the email address of the sender ( e.g. sender@filecap.com)
  2. filename – the filename of the file that needs to be send
  3. mime – the mime type of the filename that needs to be send.
  4. APIKey – the API Key configured in the admin portal.

Example:

To check if the file “cmd.exe” would be legitimate to send a request is as follows: https://filecap.filecapserver.com/FileCap/checkFile.jsp?sender=filecap@filecap.com&filename=cmd. ex&mime=application/exe&APIKey=NJUHIOFLJSKNFIDSLNJFD458954

If the sender, filename or mime is not allowed to send files, the XML result would be as follows:

<fileCheck>
 <!--Check whether a file can be send.-->
 <valid valid="False">False</valid>
</fileCheck>

If the all given variables are correct, the XML result would be as follows:

 <fileCheck>
 <!--Check whether a file can be send.-->
 <valid valid="True">True</valid>
</fileCheck>

Check how many files are uploaded for a given FileCap ID

checkFIle.jsp can verify if all files are received correctly after sending and can be used to check if a FileCap id is used already.

checkFile.jsp accepts the following GET/POST parameters for checking how many files are uploaded for a given FileCap ID:

  1. fileID – The FileCap ID that you want to query.
  2. APIKey – the API Key configured in the admin portal.

Example:

To check how many files are correctly uploaded for the FileCap ID “jklfds98” the correct request would be:

https://filecap.filecapserver.com/FileCap/checkFile.jsp?fileID=jklfdsl98&APIKey=NJUHIOFLJSKNFIDSL NJFD458954

The result of this request will be an XML stating how many files are uploaded for the given ID:

<filesUploaded>
 <!--Check if the files are uploaded.-->
 <amount amount="1">1</amount>
</filesUploaded>

invite.jsp

invite.jsp can be used to send an invite to an external party. I

invite.jsp accepts to following parameters:

  1. senderEmail – Email address of the party that is going to send the FileCap files.
  2. receiverEmail – Email address of the person sending the request.
  3. Id – the FileCap ID that you want to use for the invitation.
    1. Needs to start with iiiii.
    2. Needs to end in 25 random alphanumeric characters.
  4. APIKey – The API Key configured in the admin portal.
  5. notify – (option al) Option to set if the FileCap portal needs to send an email with the invitation to the external party. This can be used if you don’t want to send out email via you own application.

Example:

To send out an invitation to the user “receiver@filecap.com” from the user “filecap@filecap.com” the correct request is:

http://filecap.filecapserver.com/FileCap/invite.jsp?senderEmail=filecap@filecap.com&receive rEmail=receiver@filecap.com&id=iiiiinvkfdlnvkla&APIKey=NJUHIOFLJSKNFIDSLNJFD458954

The user will not receive an email with the invitation link from the FileCap server, so you can customize the invitation for you application. When you would set the notify parameter to “true” FileCap will also send out an email to the email address “receiver@filecap.com”

The result of an invite can be either true or false.
When an invite is successful, the result will be true.

When an invite cannot be made, the result will be false.

Next to that there will be an error message with a description of the problem.
The following text can be in the error message:

CANNOT_SEND_MAIL        - The mailserver is not able to process the mail. 
CANNOT_ADD_INVITE_TO_DB - FileCap was not able to add the invite ID to the DB. 
UNKNOWN_ERROR           - An exception is raised. Please check the server logs for the full exception.

process_upload.jsp

The process_upload page can be used to upload files to the FileCap portal.

The data that is being send needs to be in an multipart/form HTTP POST.

The parameters are as follows:

  1. subject – The subject of the File transfer
  2. comment – The commend for the File transfer
  3. password – The password for the file transfer, can be optional or mandatory.
  4. from – The email address of the file sender
  5. ids – The ID of the File transfer
  6. rec[0-100] – A list of receivers of the File transfer. First receiver would be rec0, second rec1 and the next rec2, rec3 etc.

Example:
Some example code for sending a file via a HTTP POST request to FileCap:

String url = "https://filecap.filecapserver.com/FileCap/process_upload.jsp";
HttpWebRequest wr = (HttpWebRequest)WebRequest.Create(url);
Stream rs;
NameValueCollection nvc = new NameValueCollection();
long uploaded = 0;
nvc.Add("subject", “test”);
nvc.Add("ids", RANDLY_GENERATED_FILECAP_ID);
nvc.Add("password", “testpass”);
nvc.Add("from", “filecap@filecap.com”);
nvc.Add("comment", “This is a test”);
nvc.Add("APIKey", “IJOKFDHSNMFDLSNMFKDLSFDLS6789678DSJ”);
nvc.Add("rec0", “receiver@filecap.com”);
nvc.Add("rec1", “receiver2@filecap.com”);
string boundary = "---------------------------" + DateTime.Now.Ticks.ToString("x");
byte[] boundarybytes = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "\r\n"); string headerTemplate =
"Content-Disposition: form-data; name=\"{0}\"; filename=\"" + fileName + "\"\r\nContent-Type: {2}\r\n\r\n";
string header = string.Format(headerTemplate, "file", fileName, "image/jpeg");
byte[] headerbytes = System.Text.Encoding.UTF8.GetBytes(header);
string formdataTemplate = "Content-Disposition: form-data; name=\"{0}\"\r\n\r\n{1}";
byte[] trailer = System.Text.Encoding.ASCII.GetBytes("\r\n--" + boundary + "--\r\n");
wr.ContentType = "multipart/form-data; boundary=" + boundary;
wr.Timeout = 50000;
wr.Method = "POST";
wr.KeepAlive = true;
int bufferExtention = 0;
foreach (string key in nvc.Keys)
{
 bufferExtention = bufferExtention + boundarybytes.Length;
 string formitem = string.Format(formdataTemplate, key, nvc[key]);
 byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
 bufferExtention = bufferExtention + formitembytes.Length;
}
wr.ContentLength = fileStream.Length + headerbytes.Length + boundarybytes.Length + bufferExtention + 50;
wr.AllowWriteStreamBuffering = false;
rs = wr.GetRequestStream();
foreach (string key in nvc.Keys)
{
 rs.Write(boundarybytes, 0, boundarybytes.Length);
 string formitem = string.Format(formdataTemplate, key, nvc[key]);
 byte[] formitembytes = System.Text.Encoding.UTF8.GetBytes(formitem);
 rs.Write(formitembytes, 0, formitembytes.Length);
}
rs.Write(boundarybytes, 0, boundarybytes.Length);
rs.Write(headerbytes, 0, headerbytes.Length);
byte[] buffer = new byte[4096];
int bytesRead = 0;
long totalSize = fileStream.Length;
while (((bytesRead = fileStream.Read(buffer, 0, buffer.Length)) != 0))
{
 uploaded += bytesRead;
 rs.Write(buffer, 0, bytesRead);
}
rs.Write(trailer, 0, trailer.Length);
rs.Close();

It is possible to send multiple files to the FileCap server using the FileCap ID. Every file that is sent is a new request to the filecap server.

The result of file that is sent can be either true or false.
When the file transfer was successful, the result will be true.

When the false send was unsuccessful, the result will be false with an error message.
The following text can be In the error message:

VIRUS_FOUND - There is a virus found in the uploaded file. The transfer has been cancelled. 
NO_RECIPIENT_GIVEN - You did not specify any recipients for the transfer. FILETYPE_NOT_ALLOW - The filetype is not allowed, either because of a forbidden 
MIME TYPE or forbidden file extension. 
PASSWORD_MANDATORY_BUT_NOT_GIVEN - The administrator set the use of a password as mandatory, but none is given in the transfer options. 
CANNOT_SEND_MAIL - The FileCap server was not able to send the email. Most commonly either the mail server was not configured correct, or the FileCap server is not authenticated to relay mail. 
API_KEY_INVALID - The given API Key was invalid and cannot be used. 
GENERAL_ERROR - There was an unknown error. Please check the server logs for the exception. If this error occurs you probably have a network / proxy issue