2016

Table Of Contents
Request object name: AddFileRequest
// STEP 1 (COMMON FOR ALL REQUESTS):
com.quark.qxpsm.QRequestContext rc = new com.quark.qxpsm.QRequestContext();
Example,
object model
if(!this.DocumentSettings1.documentName.Text.Equals(""))
rc.documentName = this.DocumentSettings1.documentName.Text;
Stream theStream = uplTheFile.PostedFile.InputStream;
long length = theStream.Length;
Byte[] Buffer = new Byte[length];
const int BUFFER_SIZE = 10000;
int nBytesRead = 0,iCount = 0;
long remainingBytes = length BUFFER_SIZE;
if(remainingBytes > BUFFER_SIZE)
{
nBytesRead = theStream.Read(
Buffer,iCount * BUFFER_SIZE,BUFFER_SIZE);
while(0 != nBytesRead)
{
iCount++;
remainingBytes = length (iCount * BUFFER_SIZE);
if(remainingBytes > BUFFER_SIZE)
nBytesRead = theStream.Read(
Buffer,iCount * BUFFER_SIZE,BUFFER_SIZE);
else
{
nBytesRead = theStream.Read(
Buffer,iCount * BUFFER_SIZE,(int)remainingBytes);
break;
}
}
}
else
nBytesRead = theStream.Read(
Buffer,iCount * BUFFER_SIZE,(int)remainingBytes);
AddFileRequest addfilereq = new AddFileRequest();
addfilereq.fileData = Buffer;
rc.request = addfilereq;
// Create the service and call it with QRequestContext object
RequestService svc = new RequestService();
QContentData qc = svc.processRequest(rc);
The object model uses SOAP to transfer data, and SOAP encoding is not the most efficient way
to transfer binary data. If you have to add a file using QuarkXPress Server Manager, the best way
is to use a POST request in a QuarkXPress Server Manager URL. You might use QuarkXPress
Manager to add a file if you wanted to add the file to all registered QuarkXPress Server instances
at one time (assuming the instances are not sharing a single document pool).
For more information, see the "AddFileRequest" .NET, Java, and Objective-C samples in the
QuarkXPress Server Manager SDK samples.
The following is a sample of a POST request HTML form.
<HTML>
<HEAD><TITLE>Test Addfile</TITLE></HEAD>
Notes
<BODY>
File will always be uploaded with name new.qxp
<FORM ACTION="http://localhost:8080/addfile/new.qxp"
METHOD = "post" ENCTYPE="multipart/form-data">
Please select the file you want to upload:
<INPUT TYPE=file NAME="uploadFile"><br><br>
<INPUT TYPE=submit VALUE="Submit">
</FORM>
</BODY>
</HTML>
148 | A GUIDE TO QUARKXPRESS SERVER 2016
USING QUARKXPRESS SERVER