Oracle WebCenter Sites (MOSC)

MOSC Banner

REST API create a new Asset containing a Blob Attribute

edited Jan 30, 2016 9:43AM in Oracle WebCenter Sites (MOSC) 1 commentAnswered

Hi ALL,

I'm in a trouble using REST API.

My issue is to create a new Asset in Management system via REST from Delivery system.

I collect all input from a form in Delivery, create a AssetBean and send it to Management system.

If I create a Asset that doesn't contain Blob Attribute, it works fine.

If I create a Asset that contains Blob Attribute, it fails.

My code is here:

String directoryExport = ics.GetProperty("cd.TempFolder." + ics.GetVar("site"), "KeepUp.ini", true);

String imageFile = directoryExport + ics.GetVar("UserPhototxt");

// salvataggio immagine su disco
FileOutputStream stream = new FileOutputStream(imageFile);
try {
    stream.write(ics.GetCgi("UserPhoto").getBlob());
} catch (Exception e) {
    log.error("Errore salvataggio immagine: " + e);
    resultStatus = "ERROR";
    resultError = "Errore salvataggio immagine: " + e.getMessage();
} finally {
    stream.close();
}

..............

// Step 7: Instantiate and define the AssetBean for the asset
AssetBean sourceAsset = new AssetBean(); // com.fatwire.rest.beans.AssetBean

// Name - mandatory field
sourceAsset.setName("Test Nicola PUT");

// Add attributes / associations / parents as in the Asset type
// definition
Attribute sourceAssetAttribute = new Attribute(); // com.fatwire.rest.beans.Attribute
Data sourceAssetAttributeData = new Data(); // com.fatwire.rest.beans.Attribute.Data
sourceAssetAttribute.setName("ImageName");
sourceAssetAttributeData.setStringValue("Test Nicola");
sourceAssetAttribute.setData(sourceAssetAttributeData);
sourceAsset.getAttributes().add(sourceAssetAttribute);

File image = new File(imageFile);

String folderName =
Tagged:

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center