Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

Asset Manager for Video Upload to DAM

sona4ever
Level 2
Level 2

Hi,

I am using the Asset Manager API to get the video in inputStream from a URL and then calling the createAsset function on it. All the attributes passed have non-null values in it. Still, the createAsset function fails with a Null Pointer Exception when I am trying it for videos. However, while uploading the image files to DAM, this method works.
I am setting the mimeType to be video/mp4. Below is the erroneous code-

if (videoURL.contains(".")) {

  mimeType = MigrationUtil.getMimeType(videoURL);

  fileName = videoURL;

}

GetMethod videoRestResponse = downloadVideo (videoURL);

int videoSize = 0;

if (HttpStatus.SC_OK == videoRestResponse.getStatusCode()) {

   try {

  videoSize = videoRestResponse.getResponseBody().length;

   LOG.debug("Video Size: {} ", videoSize); -->not null

  inputStream = getInputStream(videoRestResponse.getResponseBody());

  String newFile = MigrationConstants.IDZ_DAM_PATH_VIDEO ;

   LOG.debug ( "NEW FILE {} ",newFile ); --> not null

   LOG.debug ( "INPUT STREAM {} ", inputStream );  --> not null

   LOG.debug ( "MIME TYPE {} ", mimeType ); --> video/mp4

   if (null != assetMgr && videoSize > MigrationConstants.ZERO ) {

  

  assetMgr.createAsset(newFile, inputStream, mimeType, true); --> Null pointer exception

  }

  } catch (MalformedURLException | NullPointerException ex) {

   LOG.error("Malformed OR Null Exception occurred: {}", ex.getMessage(), ex);

  } catch (Exception ex) {

   LOG.error("Exception occured", ex.getMessage(), ex);

  } finally {

  IOUtils.closeQuietly(inputStream);

  }

}

So, despite of having all the values within the attributes, I am unable to get as to why the createAsset() function is failing. Is it something to do with just the videos?

I have also tried createAssetBinary() function that does not throw any exception, but, also does not create any asset in the DAM.
Any insights on this will be helpful. Or if I could get some reference for saving a video asset in DAM from any source URL, that would be helpful as well.

Thank you!

Sonakshi

0 Replies