Bukimedia / PrestaSharp

CSharp .Net client library for the PrestaShop API via web service
GNU General Public License v3.0
154 stars 152 forks source link

Error adding images to categories #50

Closed megonzalez closed 10 years ago

megonzalez commented 10 years ago

Hi, I've tried this code to add an image of a category:

    ImageFactory oImageFactory = new ImageFactory(tbUrlBase.Text, tbUser.Text, tbPassword.Text);

    oImageFactory.AddCategoryImage((long)6, @"D:\Temp\Category.jpg");
    //oImageFactory.AddCategoryImage((long)6, File.ReadAllBytes(@"D:\Temp\Category.jpg"));

And the following error occurs

<?xml version="1.0" encoding="UTF-8"?>
<prestashop xmlns:xlink="http://www.w3.org/1999/xlink">
<errors>
<error>
<code><![CDATA[76]]></code>
<message><![CDATA[Image upload error : formato de imagen no reconocida; use los formatos: gif, .jpg, .png]]></message>
</error>
</errors>
</prestashop>
HttpStatusCode: BadRequest

The error occurs in prestashop 1.6.0.6 and 1.5.6.1 with 2 sintaxis:

    public void AddCategoryImage(long? CategoryId, string CategoryImagePath)
    {
        this.AddImage("categories", CategoryId, CategoryImagePath);
    }

    public void AddCategoryImage(long? CategoryId, byte[] CategoryImage)
    {
        this.AddImage("categories", CategoryId, CategoryImage);
    }

Thank you.

EduLeonPavon commented 10 years ago

Hello @megonzalez I think that the problem is related with your image file. Have you tried with other images? Regards.

megonzalez commented 10 years ago

Hello EduLeonPavon,

The image used (Category.jpg) is category 6 (Women/Tops) of demo Shop of Prestashop 1.6.0.1 I test other images and always occurs the same error.

Regards.

EduLeonPavon commented 10 years ago

Hello again, Could you use PrestaShop 1.6.0.6? Best regards.

citrusO2 commented 10 years ago

It could be that the error message from prestashop is wrong and the image cannot be uploaded because it already exists on the server, have you tried out an image not already on the server?

megonzalez commented 10 years ago

Sorry for the delay, i was out of the office these days.

I testing with Prestashop 1.6.0.6 and 1.5.6.1 and both get the same error. I add the image in backoffice of Prestashop 1.6.0.6 and no error occurs. I delete de image and try add by Prestasharp (05/05/2014) and the error occurs.

There is some prerequisite in the server side ?

I install the latest version of Wamp (x64) in testing PC with W7 (x64) + Prestashop 1.6.0.6.

Regards.

EduLeonPavon commented 10 years ago

Hello @megonzalez I can´t answer your question. We always use optimised servers for PrestaShop (CentOS+Apache). Sorry.

citrusO2 commented 10 years ago

When developing i also had problems uploading the images, turned out that WAMP was creating problems (e.g. Multithreading-Requests crashed Apache, after updating to a new WAMP-Version picture upload did not work and so on..). Try a virtual machine with a linux distribution and apache/php/mysql.

megonzalez commented 10 years ago

I install Prestashop 1.6.0.6 in external server (dynahost with Lamp) and upload images OK.

The problem is with WAMP.

Thanks EduLeonPavon and citrusO2.

EduLeonPavon commented 10 years ago

Excellent :+1:

lock[bot] commented 4 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.