• 0
polach

Laravel con SDK sube mal las imágenes de forma local.

Question

Buenas a todos. Estoy trabajando en una importante empresa de Argentina y me asignaron la creación de una publicación a MercadoLibre por medio de una API-REST y cuando reviso el proyecto ya tenia instalado el SDK de Meli.

Cuando quiero hacer la subida de la imagen probé de varias formas posibles y la mas cercana a funcionar es esta ultima:

if ($request->hasFile('image')) {

    $proof = $request->file('image')->store('MeliMage');

    $meli = new Meli(env('MELI_APP'), env('MELI_SECRET_KEY'), $accessToken->access_token, $accessToken->refresh_token);

    $params=array('access_token' => $accessToken->access_token);

    $url = Storage::url($proof);
    $source = array('source' => $url);

    $upimage = $meli->post('/pictures', $source,  $params);


 return $upimage;
}

Lo hago subiendo al server ya que de forma local no me funcionaba, pero me da el mismo problema que de forma local, como si no llegara a la imagen.

El mensaje devuelto es: 

{
  "body": {
    "id": "804426-MLA31523452943_072019",
    "max_size": "500x500",
    "dominant_color": null,
    "crop": {
      "y_size": null,
      "x_size": null,
      "y_offset": null,
      "x_offset": null
    },
    "variations": [
      {
        "size": "500x500",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/F-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/F-ES.jpg"
      },
      {
        "size": "500x500",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/O-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/O-ES.jpg"
      },
      {
        "size": "400x400",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/C-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/C-ES.jpg"
      },
      {
        "size": "320x320",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/V-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/V-ES.jpg"
      },
      {
        "size": "280x280",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/E-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/E-ES.jpg"
      },
      {
        "size": "250x250",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/P-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/P-ES.jpg"
      },
      {
        "size": "228x228",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/A-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/A-ES.jpg"
      },
      {
        "size": "210x210",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/Y-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/Y-ES.jpg"
      },
      {
        "size": "200x200",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/N-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/N-ES.jpg"
      },
      {
        "size": "160x160",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/T-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/T-ES.jpg"
      },
      {
        "size": "160x160",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/Z-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/Z-ES.jpg"
      },
      {
        "size": "120x120",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/G-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/G-ES.jpg"
      },
      {
        "size": "90x90",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/I-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/I-ES.jpg"
      },
      {
        "size": "90x90",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/S-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/S-ES.jpg"
      },
      {
        "size": "70x70",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/R-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/R-ES.jpg"
      },
      {
        "size": "40x40",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/M-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/M-ES.jpg"
      },
      {
        "size": "800x800",
        "url": "http:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/B-ES.jpg",
        "secure_url": "https:\/\/http2.mlstatic.com\/resources\/frontend\/statics\/processing-image\/1.0.0\/B-ES.jpg"
      }
    ],
    "source": "http:\/\/localhost\/storage\/MeliMage\/AueuxOSdNJ249SQ7ZY6Kk66cWsG4Sv2j9cWu6MWM.png"
  },
  "httpCode": 201
}

Espero me puedan dar una mano porque me esta volviendo loco.

Saludos.

PD: La carpeta storage es publica por el momento.

Share this post


Link to post
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now