Comments (6)
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.
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.
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.
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.
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.
@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)
- when uploading image it is adding image/jpeg for Content-Type ? HOT 4
- this sdk is the worst api i've ever worked with HOT 1
- PHP8.2 HOT 4
- difference in api explorer and sdk for creating a device code with product type set HOT 2
- 415 Unsupported Media Type while trying to use getInvoice HOT 2
- Order type and sources should be cleaned up HOT 4
- "failed to open stream: No such file or directory" in error in JsonMapper.php file. HOT 4
- Singular name, should be plural? HOT 2
- Fatal error when `php_uname()` is disabled for security reasons. HOT 6
- Currency is not mapped in the ListPayoutsResponse HOT 5
- Now getCheckoutPageUrl() returning a Reletive url HOT 3
- PHP Type Error HOT 3
- Op Cache can break response types, leading to a PHP Error HOT 1
- Error: Class 'Square\SquareClient' not found HOT 1
- Fatal Error for DELIVERY Orders HOT 7
- open_basedir restriction error in JsonMapper HOT 1
- unirest-php has removed static entities in the latest release HOT 2
- PHP version required HOT 2
- Support mocking of `HttpClient` in `SquareClient
- Has error related to booking api HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from square-php-sdk.