I'm trying to upload an image via content management API. What I want to achieve is: Upload the image to the predefined Image content model and fetch the url later via the Content Delivery API - basically I wish to use Contentful as my own image server storage.
Is there any way to send the image as a base64 string/byte array? The media object type the CMA expects is not very clear to me and I've tried sending an image as a byte array but it complains that "Links must be Objects and not Arrays" . Here is what I have so far:
public static void createImageEntity(byte[] imageAsBase64, String name) {
// Create the client with given acces token
final CMAClient client = new CMAClient
.Builder()
.setAccessToken(CDA_TOKEN)
.build();
// Create new entry for given client
final CMAEntry entry = new CMAEntry()
.setId(name + "-id")
.setField("title", name, "en-US")
.setField("photo", imageAsBase64, "en-US");
final CMAEntry createdEntry = client
.entries()
.create(SPACE_ID, IMAGE_CONTENT_TYPE_ID, entry);
}