# Shopwareapi Images mit base64 hochladen bzw. aktualisieren

**URL:** <https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311>\
**Category:** Programmierung\
**Created:** [25. April 2016 um 14:32 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311 "2016-04-25T14:32:21Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![woernie](https://avatars.discourse-cdn.com/v4/letter/w/58956e/32.png) [@woernie](https://forum.shopware.com/u/woernie)\
**Post date:** [25. April 2016 um 14:32 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/1 "2016-04-25T14:32:21Z")

</div>

Hallo,

_Version Shopware 5.1.5_

ich hänge gerade bei der shopware api mit dem Artikelupload und den den Bildern. Ich möchte die Bilder gerne in base64 hochladen. Mein Modul ist in Perl geschrieben. Ich benutze LWP für die Übertragung.

das @array aus welchen ich den json generiere:

$VAR1 = {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚active‘ =\> 1,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚description‘ =\> ’

test

Hier war A

**fett**

',  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚images‘ =\> [  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&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nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ]  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; },  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚name‘ =\> ‚Kopfsalat Wintersalat‘,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚supplier‘ =\> ‚AR‘,  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ‚taxId‘ =\> 4  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; };

LWP/JSON Request: ‚\_content‘ =\> '{„taxId“:4,„name“:„Kopfsalat Wintersalat“,„description“:"

test

Hier war A

**fett**

",„mainDetail“:{„prices“:[{„from“:1,„price“:„1.87000“,„customerGroupKey“:„EK“}],„inStock“:„2288.00000“,„number“:„11215“},„supplier“:„AR“,„active“:1,„images“:[{„extension“:„jpg“,„position“:3,„url“:„data:image/jpeg;base64,/9j/4AAQSkZJRgABAQEBLAEsAAD/2wBD~…~Dnc3JGRdb6hRRRavH+rPv8AZ//Z“,„description“:„testheute“,„path“:„hahn.jpg“}]}’,

~…~ ist ein Platzhalter für den Rest

Der LWP/json request sieht auch soweit in Ordung aus und liefert ein success:true. Alle Daten werden auch in die Datenbank geschrieben, auch die ‚description‘ =\> ‚testheute‘,‚extension‘ =\> ‚jpg‘,‚path‘ =\> ‚hahn.jpg‘,‚position‘ =\> 3 in s\_articles\_img. Ich find das Bild aber nirgends. Ich hätte gedacht, dass das Bild jetzt unter \>shopware/media/ oder \>shopware/media/images oder \>shopware/media/temp oder \>shopware/media/unknown liegen müsste. Was könnte falsch sein oder was hab ich nicht beachtet. Shopware hab ich nicht soviel Ahnung hab aber zu der Api alles Mögliche an Dokumentation gelesen.

Danke

---

<div class="post-metadata">

**Author:** ![woernie](https://avatars.discourse-cdn.com/v4/letter/w/58956e/32.png) [@woernie](https://forum.shopware.com/u/woernie)\
**Post date:** [25. April 2016 um 18:23 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/2 "2016-04-25T18:23:06Z")

</div>

gelöst musste link =\> anstatt url=\> sein

---

<div class="post-metadata">

**Author:** ![brettvormkopp](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/brettvormkopp/32/7788_2.png) [@brettvormkopp](https://forum.shopware.com/u/brettvormkopp)\
**Post date:** [25. April 2016 um 19:18 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/3 "2016-04-25T19:18:38Z")

</div>

Hallo, das sieht ja interessant aus. Ist das eine Alternative um nicht Bilder parallel erst in einem Bildordner hochzuladen?

---

<div class="post-metadata">

**Author:** ![woernie](https://avatars.discourse-cdn.com/v4/letter/w/58956e/32.png) [@woernie](https://forum.shopware.com/u/woernie)\
**Post date:** [26. April 2016 um 06:07 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/4 "2016-04-26T06:07:37Z")

</div>

Ja das ist eine Alternative. Ich weiss noch nicht wie das mit der Perfomance sich verhält, wenn man mehrere hundert oder tausend Artikel hochlädt. Und ob ich die alten Bilder erst löschen muss.

---

<div class="post-metadata">

**Author:** ![mobilize](https://avatars.discourse-cdn.com/v4/letter/m/7ba0ec/32.png) [@mobilize](https://forum.shopware.com/u/mobilize)\
**Post date:** [10. Mai 2016 um 15:07 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/5 "2016-05-10T15:07:19Z")

</div>

Ich meine, dass Shopware bei jeder Artikelaktualisierung erneut ein Bild anliegt. D.h. es gibt Performance und irgendwann Speicherplatz Probleme. Man müsste daher immer erst prüfen, ob das jeweilige Bild bereits zugeordnet ist.

---

<div class="post-metadata">

**Author:** ![woernie](https://avatars.discourse-cdn.com/v4/letter/w/58956e/32.png) [@woernie](https://forum.shopware.com/u/woernie)\
**Post date:** [10. Mai 2016 um 17:42 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/6 "2016-05-10T17:42:01Z")

</div>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; \_\_options\_images&nbsp; =\> { replace =\> 1, },

Löscht alle vorhanden Bilder und ordnet die neuen zu. Ich glaube das geht aber nur mit Shopware 5

---

<div class="post-metadata">

**Author:** ![Tammo](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Tammo](https://forum.shopware.com/u/Tammo)\
**Post date:** [10. Oktober 2016 um 10:06 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/7 "2016-10-10T10:06:13Z")

</div>

hallo woernie

&nbsp;

wie ist nun dein erfarhungsbericht? funktioniert das? und geht es mit dem base64 nur direct beim artikel erstellen oder auch als medienupload unter /api/media als ‘file’ ?

&nbsp;

LG

---

<div class="post-metadata">

**Author:** ![woernie](https://avatars.discourse-cdn.com/v4/letter/w/58956e/32.png) [@woernie](https://forum.shopware.com/u/woernie)\
**Post date:** [10. Oktober 2016 um 10:42 UTC](https://forum.shopware.com/t/shopwareapi-images-mit-base64-hochladen-bzw-aktualisieren/36311/8 "2016-10-10T10:42:43Z")

</div>

Ja, das läuft soweit alles mit dem medienupload hab ich keine Erfahrung gemacht. Ist zwar jetzt schon ne Weile her, dass ich ca 700 Artikel mit Bildern hochgeladen hatte, aber perfomancetechnisch war es ganz in Ordnung.

Grüße

Woernie
