Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Web CMS (TeamSite)
retrieve files with runtime parameter
polotoo
Hi,
I am now trying to use web services to retrieve files using runtime parameters so user can specify the height and width when they export. We created an export task with output height and output width as runtime parameter. I modified the code from sdk example:
public static String RetrieveFile( String assetID, int revisionNumber, String taskname , String outputDir, int height, int width, MediaBinServerSoap mMediaBinServer) throws Exception
{
String str = "";
int ht = height;
int wd = width;
MBTask task = mMediaBinServer.getTaskByName(taskname);
String taskid = task.getMID();
MBPrimitive [] mbprimitives = task.getMPrimitives();
MBRunTimePrimitive [] prim = new MBRunTimePrimitive[mbprimitives.length];
for (int k=0; k
MBParameter [] mbps = mbprimitives.getMParameters();
MBRunTimeParameter [] param = new MBRunTimeParameter[mbps.length];
for (int j=0; j
Object [] paras = mbps.getMElements();
MBParameterElement [] paraelement = new MBParameterElement [paras.length] ;
int v =0;
for(int i=0; i
MBParameterElement mbpe = (MBParameterElement) paras
;
if(mbpe.getMName().equalsIgnoreCase("Output Height")){
mbpe.setMValue(ht);
}
if(mbpe.getMName().equalsIgnoreCase("Output Width")){
mbpe.setMValue(wd);
}
paraelement
=mbpe;
}
MBRunTimeParameter tt = new MBRunTimeParameter();
tt.setMElements(paraelement);
param =tt;
}
MBRunTimePrimitive ss = new MBRunTimePrimitive();
ss.setMParameters(param);
prim=ss;
}
for (MBRunTimePrimitive mp : prim){
MBRunTimeParameter [] mbps = mp.getMParameters();
for (MBRunTimeParameter mbp : mbps){
Object [] paras = mbp.getMElements();
for(Object para : paras){
MBParameterElement mbpe = (MBParameterElement) para;
System.out.print(" -->"+mbpe.getMName()+"="+mbpe.getMValue()+"\n");
}
}
}
if( mMediaBinServer == null )
throw new Exception( "You have not connected to a MediaBin Web Service" );
if( assetID == null )
throw new Exception( "No asset was specified" );
ByteArrayHolder byteArray = new ByteArrayHolder();
StringHolder tagID = new StringHolder();
StringHolder jobID = new StringHolder();
//Retrieve the file...this will block until the job has completed
//if the job fails...use jobID to get the MBJob object to find the reason
mMediaBinServer.retrieveFile( assetID, revisionNumber, taskid, prim, false, byteArray, tagID, jobID);
byte[] buffer = byteArray.value;
if( buffer != null )
{
//Get the default name of the retrieved asset
String name = mMediaBinServer.getRetrievalFilename( assetID, revisionNumber, taskid );
//Create the output directory
File file = new File( outputDir );
file.mkdir();
//Create the file
file = new File( outputDir, name );
//Write the file
FileOutputStream fileStrm = new FileOutputStream( file );
fileStrm.write( buffer );
fileStrm.close();
}
MBJob job = mMediaBinServer.getJob( jobID.value );
str = ParseMBJob( job );
return str;
}
The output of the MBRuntimeprimitive [] has the same reault as MBPrimitive [] except for the values of output height and output width.
output of MBPrimitive:
-->Image Size
-->Image Sizer Parameters
-->Resampling Type=0
-->Sizing Type=0
-->Output Width=0.0
-->Output Height=0.0
-->Dimension Type=3
-->Resolution=72.0
-->Resolution Units=0
-->Constrain Proportions=false
-->JPEG Encoder
-->JPEG Quality
-->JPEG Quality=85
output of MBRuntimePrimitive:
-->Resampling Type=0
-->Sizing Type=0
-->Output Width=1000
-->Output Height=1000
-->Dimension Type=3
-->Resolution=72.0
-->Resolution Units=0
-->Constrain Proportions=false
-->JPEG Quality=85
But it doesn't seem like doing the magic, no matter what value I set, it always retrieves the image with original size. One thing I noticed is that if we export the image from web client, it prompts for values of height and width. But when we use ecm connector from TeamSite to import image, it does not pormpt at all, always the image with original size gets retrieved.
Any suggestions? Really appreciate it if anyone can give a heads-up.
Find more posts tagged with
Comments
Rick Poulin
I'm trying to figure out how to use runtime parameters myself, but if all you're doing is resizing and you know your output format, try using RetrieveAsJPEG or RetrieveAsGIF. Those are much easier to use and they take integer parameters for width and height.