Project

General

Profile

Actions

GX-Bug #70995

closed

REST API Zuordnung von Artikelbildern mit Pfad ist nicht möglich | REST API assignment of product images with path is not possible

Added by Till Tepelmann 9 months ago. Updated 2 months ago.

Status:
Erledigt
Priority:
Normal
Assignee:
-
Category:
REST-API
Target version:
% Done:

0%

Estimated time:
Steps to reproduce:
Betroffene Versionen:
4.9.3.0
Release Notes Langtext:

Via API können Produkten jetzt auch Bilder zugewiesen werden, die in Unterordnern liegen

Tags:

Description

Die Zuordnung von Artikelbilder bei Produkterstellung oder Produktupdate per Rest-API ist nicht möglich, wenn man Unterordner mit dem Dateinamen angibt.

Kann wie folgt reproduziert werden:

  1. Shop installieren
  2. Ein beliebiges Produkt öffnen, dort über eines der Bilder den ResponsiveFileManager öffnen
  3. Im Hauptverzeichnis einen neuen Ordner anlegen, z. B. "testdir"
  4. In das neue Verzeichnis wechseln und dort ein Bild hochladen, das hochgeladene Bild auswählen
  5. Den Pfad des angepassten Bildes kopieren ("testdir/")
  6. Artikel nun entweder speichern oder die Änderungen verwerfen
  7. Über API v2 ein neues Produkt erstellen oder ein existierendes aktualisieren, als "filename" bei einem der Bilder den Pfad aus Schritt 5 eintragen

Erwartetes Verhalten:
Es sollte beim Update und Insert von Artikeldaten mit Bildern auch Unterordner möglich sein, wie es auch im Gambio Admin derzeit schon möglich ist

Tatsächliches Verhalten:
Es ist nicht möglich Aritkelbilder per REST API mit Unterordner, hochzuladen, da dies immer mit einer Fehlermeldung verhindert wird.

Der Anfang der Fehlermeldung ist folgende:

{
"affected": [],
"errors": [
{
"errorMessage": "Filename \"Fahrzeugeinrichtungen/Mercedes_Benz/Vito/2121511LS1733-001/Fahrzeugeinrichtung_Mercedes_Benz_Vito_Kompakt_L1_Linke_Seite_B1.jpg\" is not valid",
"stacktrace": [
{
"file": "/www/htdocs/xxxxxx/testshop.mein-shop.de/GXEngine/Shared/FileSystem/FilenameStringType.php",
"line": 53,
"function": "validateFilenameIsNotAPath",
"class": "FilenameStringType",
"type": "->",
"args": [
"Fahrzeugeinrichtungen/Mercedes_Benz/Vito/2121511LS1733-001/Fahrzeugeinrichtung_Mercedes_Benz_Vito_Kompakt_L1_Linke_Seite_B1.jpg"
]
}

Folgende Funktion wird in der Datei aufgerufen und erzeugt die Fehlermeldung:

/**
* @param string $filename
*/
protected function validateFilenameIsNotAPath(string $filename): void
{
if ($filename !== basename($filename)) {

throw new InvalidArgumentException('Filename "' . $filename . '" is not valid');
}
}
}

Dadurch, dass ich immer eine Pfad mit bei der Übergabe angebe (Pfad1/Pfad2/Bild.jpg) wird dieser String ($filename=Pfad1/Pfad2/Bild.jpg) mit "basename(Pfad1/Pfad2/Bild.jpg)" also nur "Bild.jpg" verglichen.


The assignment of article images during product creation or product update via Rest API is not possible if you specify subfolders with the file name.

Can be reproduced as follows:

  1. Install shop
  2. Open any product and open the ResponsiveFileManager with one of the images
  3. Create a new directory in the root directory, for example "testdir"
  4. Switch to the newly created directory and upload an image. Select the image afterwards
  5. Copy the path of the changed image ("testdir/")
  6. Save the product or discard the changes
  7. Via API v2 create a new product or update an existing one using the path from step 5 as the "filename" of one of the images

Expected behavior:
When updating and inserting article data with images, subfolders should also be possible, as is currently already possible in the Gambio Admin

Actual behavior:
It is not possible to upload article images via REST API with subfolders, as this is always prevented with an error message.

The beginning of the error message is as follows:

{
"affected": [],
"errors": [
{
"errorMessage": "Filename \"Fahrzeugeinrichtungen/Mercedes_Benz/Vito/2121511LS1733-001/Fahrzeugeinrichtung_Mercedes_Benz_Vito_Kompakt_L1_Linke_Seite_B1.jpg\" is not valid",
"stacktrace": [
{
"file": "/www/htdocs/xxxxxx/testshop.mein-shop.de/GXEngine/Shared/FileSystem/FilenameStringType.php",
"line": 53,
"function": "validateFilenameIsNotAPath",
"class": "FilenameStringType",
"type": "->",
"args": [
"Fahrzeuginrichtungen/Mercedes_Benz/Vito/2121511LS1733-001/Fahrzeugeinrichtung_Mercedes_Benz_Vito_Kompakt_L1_Linke_Seite_B1.jpg"
]
}

The following function is called in the file and generates the error message:

/**
* @param string $filename
*/
protected function validateFilenameIsNotAPath(string $filename): void
{
if ($filename !== basename($filename)) {

throw new InvalidArgumentException('Filename "' . $filename . '" is not valid');
}
}
}

Because I always specify a path with the transfer (path1/path2/image.jpg), this string ($filename=path1/path2/image.jpg) is compared with "basename(path1/path2/image.jpg)", i.e. only "image.jpg".


Actions #1

Updated by Rico Schreiber 7 months ago

  • Status changed from Gemeldet to Anerkannt
Actions #3

Updated by Rico Schreiber 7 months ago

  • Description updated (diff)
Actions #4

Updated by Rico Schreiber 7 months ago

  • Tags set to 5.0.1.0
  • Status changed from Anerkannt to In Bearbeitung
  • Assignee set to Rico Schreiber
  • Target version set to 5.0.1.0
  • Release Notes Langtext updated (diff)
Actions #5

Updated by Rico Schreiber 7 months ago

  • Subject changed from REST API Zuordnung von Artikelbildern mit Pfad ist nicht möglich to REST API Zuordnung von Artikelbildern mit Pfad ist nicht möglich | REST API assignment of product images with path is not possible
Actions #7

Updated by Rico Schreiber 7 months ago

  • Status changed from In Bearbeitung to Testing
  • Assignee deleted (Rico Schreiber)
Actions #8

Updated by Krystian Czerwinski 6 months ago

  • Assignee set to Krystian Czerwinski
Actions #9

Updated by Krystian Czerwinski 6 months ago

  • Assignee deleted (Krystian Czerwinski)
Actions #11

Updated by Rico Schreiber 4 months ago

  • Status changed from Testing to Erledigt
Actions #12

Updated by Rico Schreiber 2 months ago

  • Target version changed from 5.0.1.0 to 4.9.4.2
Actions #14

Updated by Rico Schreiber 2 months ago

  • Tags changed from 5.0.1.0 to 4.9.4.2
Actions

Also available in: Atom PDF