I am attempting to programmatically insert an image asset into MediaBin using the MediaBinService.insertAsset_URL() method. According to the MediaBin API document (release 4.6, page 314), this requires the application to do “an HTTP post” of the image to the URL returned by the MediaBinService.getUploadURL_HTTP() method.
The following code represents basically what I’m trying to do:
import org.apache.commons.httpclient.*;
MediaBinServerSoap MediaBinService;
//... Logic to connect to MediaBin ... //
// Obtain the MediaBin URL to POST this image to
// this returns “http:///mediabinwebservice/ext/upload.asp”
String targetURL = MediaBinService.getUploadURL_HTTP();
String filePath = “/path/to/some/file.jpg”;
// Create the List of Parts to add to request
ArrayList partList = new ArrayList();
partList.add(new FilePart(“ImageName”, new File(filePath)));
// Create the MultipartRequestEntity request object
PostMethod post = new PostMethod(targetURL);
post.setRequestEntity(new MultipartRequestEntity(partList.toArray(), post.getParams()));
// POST the request to MediaBin
HttpClient client = new HttpClient();
int status = client.executeMethod(post);
String mbAssetURL = post.getResponseBodyAsString();
// Output the response
System.out.println(mbAssetURL);
// INSERT the asset into MediaBin
String jobId = MediaBinService.insertAsset_URL(mbAssetURL, “file.jpg”,
, , null, 850, false);
This is the response that I get from MediaBin (the value of mbAssetURL):
[html]
xmlns:xsd="
http://www.w3.org/2001/XMLSchema"> soap

erver
Server was unable to process request. --> MBException: The filename of the uploaded file was not specified.
[/html]
Obviously that is not a MediaBin asset URL which I can pass to the MediaBinService.insertAsset_URL() method. The error suggests to me that the web service is expecting additional parameters, e.g. “filename”, since it’s complaining that the filename is not specified. However, the documentation does not really give any detail about posting to the URL provided by the MediaBinService.getUploadURL_HTTP() method.
Please note that I have also attempted including the following key/value pair in the post as well: fieldname=ImageName.
What am I missing here? Am I missing something so simple?
MediaBin: 4.6.1 sp1
Thanks in advance for your help!!!