Image File Upload via REST case Error 500 response due destination directory not set I'm struggling to upload images to the Drupal 8 site via REST. Finally, I managed to deliver the file to the server, but then the error 500 rased due destination folder not set.
I can't figure where to define this destination directory: in request JSON data or header, or somewhere else in the settings.php or somewhere in REST configuration?
Here my code in Python:
def create_drupal_image(session, oauth, media_name, image_path):
    file_size = os.stat(image_path).st_size
    with open(image_path, &quot;rb&quot;) as image_file:
        encoded_string = base64.b64encode(image_file.read())

    payload = {
        &quot;filename&quot;: [
            {
                &quot;value&quot;: media_name + &quot;.jpg&quot;
            }
        ],
        &quot;filemime&quot;: [
            {
                &quot;value&quot;: &quot;image/jpeg&quot;
            }
        ],
        &quot;filesize&quot;: [
            {
                &quot;value&quot;: str(file_size)
            }
        ],
        &quot;type&quot;: [
            {
                &quot;target_id&quot;: &quot;image&quot;
            }
        ],
        &quot;data&quot;: [
            {
                &quot;value&quot;: &quot;data:image/jpeg;base64,&quot; + str(encoded_string)
            }
        ],
        &quot;_links&quot;: {
            &quot;type&quot;: {
                &quot;href&quot;: oauth.base_url + REST_TYPE_FILE_IMAGE
            },
        }
    }
    return create_drupal_entity_impl(session, oauth, ENTITY_FILE_URL, payload)


def create_drupal_entity_impl(session, oauth, url, payload):
    payload_str = json.dumps(payload)
    # print(payload_str)
    endpoint = oauth.base_url + url
    # Set all required headers
    headers = {
        'Content-Type': 'application/hal+json',
        'Accept': 'application/hal+json',
        'Authorization': 'Bearer ' + oauth.access_token
    }
    # Post the new node (a Contact) to the endpoint.
    response = session.post(endpoint, data=payload_str, headers=headers, verify=oauth.verify)
    return handle_create_response(response)


Edited this source core/lib/Drupal/Core/File/FileSystem.php line 488 in order to print the $destination, and it appears to be empty. See '' in the server log below:
AH01071: Got error 'PHP message: Uncaught PHP Exception Drupal\\Core\\File\\Exception
\\DirectoryNotReadyException: &quot;The specified file 'temporary://filemDIAwD' could not be copied 
because the destination '' directory is not properly configured. This may be caused by a problem 
with file or directory permissions.&quot; at /var/www/vhosts/web.site/core/lib/Drupal/Core/File
/FileSystem.php line 488'

Tried to define 'file_private_path' folder in settings.php, added 'tmp' folder under 'sites/default/files' but with no result. What am I missing here?
The missing property was destination &quot;uri&quot;
&quot;uri&quot;: [
   {
      &quot;value&quot;: &quot;public://&quot; + media_name + &quot;.jpg&quot;
   }
],