Git Product home page Git Product logo

Comments (6)

StephenJosey avatar StephenJosey commented on June 27, 2024

As far as I understand, FileWrapper requires a local image/file. It sounds like you could use your own (outside of Square) request to download the file locally, and then use FileWrapper to attach it, but that would be outside of Square.

from square-php-sdk.

jtwiest avatar jtwiest commented on June 27, 2024

Thanks for the response @StephenJosey. I tried that solution in the code snippit above however.

// Save local copy of image (in prod this is coming from my s3 bucket)
$filePath = sys_get_temp_dir() . '/filename.jpeg';
$fileUrl = 'https://www.aworldofdifference.co.nz/pics/45,3,1,6,3,0/20151002142909/test-jpg.jpeg';
file_put_contents($filePath, file_get_contents($fileUrl));

I'm downloading the image from the url and putting it into my /tmp directory saving it's final path as $filePath. The $filePath variable is then what I'm providing as the input to FileWrapper::createFromPath($filePath) but my problem still persists.

from square-php-sdk.

StephenJosey avatar StephenJosey commented on June 27, 2024

Ah, sorry, I totally missed that ha. What's your app id? I can see if there's anything obvious going on in our logs.

from square-php-sdk.

jtwiest avatar jtwiest commented on June 27, 2024

Ah thanks - I believe my app id is sq0idp-sELSl3rZR8ZFMJM02n_Kfg I pulled that from https://squareupsandbox.com/dashboard/apps/my-applications

Everything above is being done on the sandbox server as well. Not sure if there is anything different about that environment either.

Thanks!

from square-php-sdk.

StephenJosey avatar StephenJosey commented on June 27, 2024

Actually, I think maybe it's because you're not passing in a mimeType (which I can see is optional). According to PHP docs, the default is "application/octet-stream": https://www.php.net/manual/en/class.curlfile.php. Could you try:

$imageFile = FileWrapper::createFromPath($filePath, "image/jpeg");

instead? I have not tested this so apologies if this doesn't help.

from square-php-sdk.

jtwiest avatar jtwiest commented on June 27, 2024

@StephenJosey you're my hero, that worked! I assumed it would have picked the mimeType up automatically and it was my image that was the problem.

It might be a good idea to make that field required in a future version since the default value is not a supported type of the api.

Really appreciate the support.

from square-php-sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.