permissions – POST Product Image w/ REST API Exception

I have Magento running in a Bitnami Docker container, and
trying to upload an image for a product using the REST API causes an exception.

I initially suspected a permissions error, so the following subdirectories of the Magento installation are CHMOD 777:

Please note I’ve removed the base64 encoded image data from the code snippet below in order to keep this post short and readable.

Not sure what else to look for – a config option maybe?.
Any pointers in the right direction appreciated.

Data I’m sending to server:

{
    "entry": {
        "content": {
            "base64_encoded_data": ***(IMAGE DATA SUPPLIED HERE, NOT SHOWN)***,
            "name": "Mizuno-2.jpg",
            "type": "image/jpeg"
        },
        "disabled": false,
        "file": "Mizuno-2.jpg",
        "id": 0,
        "label": "Mizuno 2",
        "media_type": "image",
        "position": 1,
        "types": (
            "image"
        )
    }
}

REST API Error:

2021-07-26:23:25:27,818 DEBUG    (connectionpool.py:0452) http://localhost:8080 "POST /rest/V1/products/Mizuno-2/media HTTP/1.1" 500 104
<Response (500)>
{
    "message": "Internal Error. Details are available in Magento log file. Report ID: webapi-60ff4467c74b8"
}

Server Log Exception Message:

(2021-07-26 23:25:27) main.CRITICAL: Report ID: webapi-60ff4467c74b8; Message: Notice: file_get_contents(): file created in the system's temporary directory in /bitnami/magento/vendor/laminas/laminas-http/src/PhpEnvironment/Request.php on line 96 {"exception":"(object) (Exception(code: 0): Report ID: webapi-60ff4467c74b8; Message: Notice: file_get_contents(): file created in the system's temporary directory in /bitnami/magento/vendor/laminas/laminas-http/src/PhpEnvironment/Request.php on line 96 at /bitnami/magento/vendor/magento/framework/Webapi/ErrorProcessor.php:208, Exception(code: 0): Notice: file_get_contents(): file created in the system's temporary directory in /bitnami/magento/vendor/laminas/laminas-http/src/PhpEnvironment/Request.php on line 96 at /bitnami/magento/vendor/magento/framework/App/ErrorHandler.php:61)"} ()

architecture – Updating a database directly vs using an API

I’m setting up a system where a web app reads from a postgres database and displays the results to an end user. That database is to be updated by a discord bot. The web app will be either a react or vanilla js app living on a CDN somewhere so it will communicate with the DB via an express api. The api, db, and discord bot will all live on the same vpc. My question is: Should the discord bot access the db directly (through an orm, I’m not an animal), or should it make requests to the api?

As it stands, this is an open ended, opinion based question. To make it more concrete, what are the benefits and downsides of each and is there one that clearly wins over the other in this situation?

Search API – Can’t get result items

I installed Search API, created Search Index, and it’s using the Solr server.
When I execute the query and debug the code afterward, I get 3 result counts.
And for result items, I get an empty array. When I try the same query in Solr Admin, I get 3 result counts as well as result items.

public function searchResults() {
    $parse_mode = Drupal::service('plugin.manager.search_api.parse_mode')
      ->createInstance('terms');
    $parse_mode->setConjunction('OR');

    /** @var Query $query */
    $query = Index::load('default_solr_index')->query();
    $query->addCondition('status', 'true');
    $query->setOption('bq', 'base_site_url:"' . 'http://test.local' . '"^4');
    $query->keys('editor');
    $query->setLanguages(('en'));
    $query->setFulltextFields(('field_summary'));
    $query->range(50, 10);
    $query->setParseMode($parse_mode);
    $query->addTag('custom_search');

    $data = $query->execute();

    $results = $data->getResultItems(); // I get empty array
    $resultCount = $data->getResultCount(); // I get int 3
  }

I tried to change this line of code:

    $query->range(50, 10);

to:

    $query->range(0, 10);

But I get this error:

Argument 4 passed to Drupalsearch_api_solrPluginsearch_apibackendSearchApiSolrBackend::getHighlighting() must be of the type array, null given, called in /var/www/html/my-project/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php on line 2748

What am I doing wrong?
This is my code and I use the Drupal 8 version.

api – Google credentials and redirect URI for Google OAuth2 in a WordPress plugin, questions

I’m developing a plugin that inserts contacts into a custom table of the WordPress database (name, phone number, email). It is possible to enter data in this table either manually, through a form, or by importing it from WordPress users. I have also developed a feature to import contacts from Google Contacts (Google People). Everything works but I ask you: when I will provide the plugin to my customers how can I do to avoid also providing the client_secret.json file with my credentials for accessing the Google API via OAuth2 together with the plugin?
Furthermore, in order to function correctly, I must also authorize the URI redirect in the Google console but I cannot know in advance the URL of the various sites where the plugin will be installed, is it possible to automate (perhaps always through the Google API) this insertion?

c++ – API for input stream with read until

I want to create a stream class The input stream should read/parse a continuous range from left to right providing convenience methods. The implementation isn’t a problem but choosing a consistence API.

A basic example would be:

input_stream is("Hello! 42");

is.peak(); // 'H'
is.read_n(7); // "Hello! "
is.read<int>(); // 42

I also want to support an operation known as read until to read the input stream until a specific string occurs. On first glance, this doesn’t sound very problematic but if you take a closer look there are 3 possible outcomes:

input_stream is("Hello! 42");

is.read_until("!"); // ?
  1. function returns “Hello!”, input stream points to ” 42″
  2. function returns “Hello”, input stream points to ” 42″
  3. function returns “Hello”, input stream points to “! 42”

My idea is to support all 3 variants with 3 different functions which should be unambiguous to the reader but it is really hard to explain what actually happen. Here are my ideas:

• read_until_include(cmp) – process the cmp and returns the part before + cmp

• read_until_exclude(cmp) – process the cmp but returns only the part before

• read_up_to(cmp) – does not process the cmp and
returns only the part before (leaves the cmp in the input stream)

I am not a big fan of my own idea. Could anyone please give me an advice where to go from here?

api design – API for input stream operation read until

I want to create a stream class The input stream should read/parse a continuous range from left to right providing convenience methods. The implementation isn’t a problem but choosing a consistence API.

A basic example would be:

input_stream is("Hello! 42");

is.peak(); // 'H'
is.read_n(7); // "Hello! "
is.read<int>(); // 42

I also want to support an operation known as read until to read the input stream until a specific string occurs. On first glance, this doesn’t sound very problematic but if you take a closer look there are 3 possible outcomes:

input_stream is("Hello! 42");

is.read_until("!"); // ?
  1. function returns “Hello!”, input stream points to ” 42″
  2. function returns “Hello”, input stream points to ” 42″
  3. function returns “Hello”, input stream points to “! 42”

I want to support all 3 variants with 3 different functions which should be unambiguous to the reader but it is really hard to explain what actually happen. Here are my ideas:

• read_until_include(cmp) – process the cmp and returns the part before + cmp

• read_until_exclude(cmp) – process the cmp but returns only the part before

• read_up_to(cmp) – does not process the cmp and
returns only the part before (leaves the cmp in the input stream)

I am not a big fan of my own idea. Could anyone please give me an advice where to go from here?

angular reactive form custom validator returning value from the API

I have a API the validate claim and returns an object of valid which is true or false and messageLst

I need the custom validate is used display the messageLst by looping throught the values

Google drive API

(help) is there anyone who have already approved Google drive API? And wanted to sell it? Please help me

Search API – Can’t get result items

I installed Search API, created Search Index, and it’s using the Solr server.
When I execute the query and debug the code afterward, I get 3 result counts.
And for result items, I get an empty array. When I try the same query in Solr Admin, I get 3 result counts as well as result items.

public function searchResults() {
    $parse_mode = Drupal::service('plugin.manager.search_api.parse_mode')
      ->createInstance('terms');
    $parse_mode->setConjunction('OR');

    /** @var Query $query */
    $query = Index::load('default_solr_index')->query();
    $query->addCondition('status', 'true');
    $query->setOption('bq', 'base_site_url:"' . 'http://test.local' . '"^4');
    $query->keys('editor');
    $query->setLanguages(('en'));
    $query->setFulltextFields(('field_summary'));
    $query->range(50, 10);
    $query->setParseMode($parse_mode);
    $query->addTag('custom_search');

    $data = $query->execute();

    $results = $data->getResultItems(); // I get empty array
    $resultCount = $data->getResultCount(); // I get int 3
  }

I tried to change this line of code:

    $query->range(50, 10);

to:

    $query->range(0, 10);

But I get this error:

Argument 4 passed to Drupalsearch_api_solrPluginsearch_apibackendSearchApiSolrBackend::getHighlighting() must be of the type array, null given, called in /var/www/html/my-project/modules/contrib/search_api_solr/src/Plugin/search_api/backend/SearchApiSolrBackend.php on line 2748

What am I doing wrong?
This is my code and I use the Drupal 8 version.

How to use the h5p api in D8 [closed]

I can see the list of hooks here https://git.drupalcode.org/project/h5p/blob/HEAD/h5p.api.php but i dont understand how each one gets triggered and what parameters have to be passed.

are there any online examples of how to use this api in D8 ?