---
title: Binary resources
description: Examples in this documentation depend on features activated in the ds-evaluation setup profile.
component: pingds
version: 7.3
page_id: pingds:rest-guide:binary-rest
canonical_url: https://docs.pingidentity.com/pingds/8.1/rest-guide/binary-rest.html
llms_txt: https://docs.pingidentity.com/pingds/llms.txt
docs_for_agents: https://developer.pingidentity.com/build-with-ai/docs-for-agents.md
revdate: 2023-05-16T09:42:49Z
keywords: ["REST API"]
superseded_by: https://docs.pingidentity.com/pingds/8.1/rest-guide/binary-rest.html
section_ids:
  binary-rest-mapping: Map a binary resource
  binary-rest-update: Update a binary resource
  binary-rest-read: Read a binary resource
---

# Binary resources

|   |                                                                                                                                                                                                                        |
| - | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|   | Examples in this documentation depend on features activated in the `ds-evaluation` setup profile.For details, refer to [Learn about the evaluation setup profile](../install-guide/setup-ds.html#about-ds-evaluation). |

## Map a binary resource

1. Edit the attributes section for a resource in the configuration file `/path/to/opendj/config/rest2ldap/endpoints/api/example-v1.json`.

   The following JSON excerpt maps the user `photo` property to the `jpegPhoto` LDAP attribute:

   ```none
   "photo" : { "type" : "simple", "ldapAttribute" : "jpegPhoto", "isBinary" : true },
   ```

2. Force the Rest2ldap endpoint to reread the updated configuration file:

   ```bash
   $ dsconfig \
    set-http-endpoint-prop \
    --hostname localhost \
    --port 4444 \
    --bindDN uid=admin \
    --bindPassword password \
    --endpoint-name "/api" \
    --set enabled:false \
    --usePkcs12TrustStore /path/to/opendj/config/keystore \
    --trustStorePassword:file /path/to/opendj/config/keystore.pin \
    --no-prompt

   $ dsconfig \
    set-http-endpoint-prop \
    --hostname localhost \
    --port 4444 \
    --bindDN uid=admin \
    --bindPassword password \
    --endpoint-name "/api" \
    --set enabled:true \
    --usePkcs12TrustStore /path/to/opendj/config/keystore \
    --trustStorePassword:file /path/to/opendj/config/keystore.pin \
    --no-prompt
   ```

## Update a binary resource

1. Ensure that the application has a resource to upload.

   For example, copy a JPEG photo `picture.jpg` to the current directory.

2. Upload the binary resource as a base64-encoded JSON string.

   The following example patches Babs Jensen's resource to add a profile photo:

   ```bash
   $ base64 encode --rawDataFile picture.jpg

   /9j/4AAQSkZJRgABAQEAYABgAAD/4QAWRXhpZgAASUkqAAgAAAAAAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAr/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AL+AAf/Z

   $ curl \
    --request PATCH \
    --cacert ca-cert.pem \
    --header "Content-Type: application/json" \
    --data "[{\"operation\": \"add\", \"field\": \"/photo\", \"value\": \"/9j/4AAQSkZJRgABAQEAYABgAAD/4QAWRXhpZgAASUkqAAgAAAAAAAAAAAD/2wBDAAEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/2wBDAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQH/wAARCAABAAEDASIAAhEBAxEB/8QAFQABAQAAAAAAAAAAAAAAAAAAAAr/xAAUEAEAAAAAAAAAAAAAAAAAAAAA/8QAFAEBAAAAAAAAAAAAAAAAAAAAAP/EABQRAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhEDEQA/AL+AAf/Z\"}]" \
    --silent \
    "https://kvaughan:bribery@localhost:8443/api/users/bjensen?_prettyPrint=true"

   {
     "_id" : "bjensen",
     "_rev" : "<revision>",
     "_schema" : "frapi:opendj:rest2ldap:posixUser:1.0",
     "_meta" : {
       "lastModified" : "<datestamp>"
     },
     "userName" : "babs@example.com",
     "displayName" : [ "Barbara Jensen", "Babs Jensen" ],
     "name" : {
       "givenName" : "Barbara",
       "familyName" : "Jensen"
     },
     "description" : "Original description",
     "manager" : {
       "_id" : "trigden",
       "_rev" : "<revision>"
     },
     "groups" : [ {
       "_id" : "Carpoolers",
       "_rev" : "<revision>"
     } ],
     "photo" : "<base64-encoded-photo>",
     "contactInformation" : {
       "telephoneNumber" : "+1 408 555 9999",
       "emailAddress" : "babs@example.com"
     },
     "uidNumber" : 1076,
     "gidNumber" : 1000,
     "homeDirectory" : "/home/bjensen"
   }
   ```

## Read a binary resource

1. Read the binary resource as a base64-encoded JSON string.

   The following example reads Babs Jensen's profile photo:

   ```bash
   $ curl \
    --cacert ca-cert.pem \
    --silent \
    "https://kvaughan:bribery@localhost:8443/api/users/bjensen?_fields=photo"

   {"_id":"bjensen","_rev":"<revision>","photo":"<base64-photo>"}
   ```
