I hate to admit it but part of my problem might be that I had the wrong value for month in the URL. (I am blaming that on to many hours riding herd on a hot laptop). Other complications preventing me from retesting fix. Stay tuned.
Still getting some error after fixing month value in url. Still looking around for a fix.
I am getting the same error. It is driving me batty. Any new info on the cause of the string offset error?
We got further by adding the following line to the wp-config.php file:
‘define(‘ALLOW_UNFILTERED_UPLOADS’, true);’
It got us past the rest_upload_sideload_error, but still no joy. Calling the API returns the same warning, and what looks like a valid response. But in looking at the Media Library, there is a entry made, but the image is named something like ‘unnamed-file.c’ , and the image file is corrupt.
I added the same Allow_Unfiltered and got the same result as you. I noticed in the media json reply there is a big hint:
“media_type”: “file”,
“mime_type”: “application/json”,
The media_type should be image and the mime_type should be image/jpeg (in my case).
In the body of my post I state the media_type and mime_type:
{
“date”: “2020-09-25T01:15:55”,
“title” :”test.jpg”,
“media_type”: “image”,
“mime_type”: “image/jpeg”,
“slug” : “test-logo”,
“media_attachment”: “/9j/4AAQSkZJRgABAgECWAJYAAD/wAARCADUAZAD…”
}
It appears those parameters are being ignored. Which is why WP won’t let the file upload unless the filter is turned off.
BTW, I have three sites. Two work. Only the one hosted by GoDaddy gives me this problem.
I just remembered. There is a problem with this plug-in. See the post called “Mime type media”.
You have to add a few lines to “wp-content/plugins/woo-media-api/class-woocommerce-media-api-controller.php”
This worked for me.
Thanks for the tip. For reference, I searched for the post and found https://ww.wp.xz.cn/support/topic/mime-type-image/. I passed it on to the server guy and we will give it a try. Stay tuned.
Getting there but not sure I am home yet. I can upload an image via Postman but
1. Still get the warning html ‘<b>Warning</b>: Illegal string offset ‘rendered’ in…’ before what looks like a vaild response.
2. The filename is apparently generated by the system like ‘T’, ‘T-1’
3. And the url does not indicate it points to a jpg, e.g. ‘http://aaaaa.org/wp content/uploads/2020/10/T-2’ . Uploads via WooCommerce web site have url like ‘http://aaaaa.org/wp-content/uploads/2020/09/IMG_20200902_093420-1.jpg
But I see the photo in media library. Going to carry on and add the urls to the product to see if the photos will display with the product OK.
-
This reply was modified 5 years, 7 months ago by
efoertsch.
-
This reply was modified 5 years, 7 months ago by
efoertsch.
OK. Here’s a bit of a summary that will hopefully save someone hours or days of spinning wheels.
Got everything working for product and image uploads and Android app is being used in production. Here’s abbreviated WC setup I used.
1. Created ‘Android App’ user.
2. Created WC API key for ‘Android App’ and set access to ‘Read/Write’
3. Applied FAST CGI fix and JSON basic auth – https://support.metalocator.com/en/articles/1654091-wp-json-basic-auth-with-fastcgi
4. To keep WP from overwriting above changes also updated .htaccess file per https://perishablepress.com/stop-wordpress-changing-htaccess/.
5. Installed WC Media API – https://ww.wp.xz.cn/plugins/woo-media-api/
6. Activated WC Media API Plugin
7. Updated WC plugin file – https://ww.wp.xz.cn/support/topic/mime-type-image/
8. In my particular case every WC product is unique with it’s own SKU. To upload photos with image names related to the SKU, the SKU with appended photo sequence number were placed into the media.title.raw and media.title.rendered fields (Otherwise photos got names of ‘T’, ‘T-1’ as noted in prior post)
9. But WC would duplicate the photos uploaded and assign an additional sequence number, i.e. if I uploaded image SKU-01.jpg it created a SKU-01-1.jpg and then associated SKU-01-1.jpg to the product. The original uploaded photo was then extraneous. So my app logic was:
a. Upload product info to create new product
b. Upload photo(s), use the returned source_url value in next step
c. Associate photos to product by updating product, placing source_url value into product.image.src field
d. Delete the original uploaded photos
Hello @efoertsch Thank you very much for your solutions, I just have a question, where are the media.title.raw and media.title.rendered fields, I can’t find them, you can extend the explanation of those two fields, Thanks
(I think this is what happened. Haven’t thought about the code since I posted above what I ended up doing.)
I found those fields via the returned JSON from the WP Media API after my initial success in uploading a photo via the WC Media API. The documentation from https://developer.ww.wp.xz.cn/rest-api/reference/media/ is pretty sparse on details. Note the title field is defined as an object, but there are not details as to what is contained in the object. On examining the returned media JSON I saw those fields in the title field and gave them a try to see if the photos would retain the proper SKU-01 type naming convention – which they did.