Upload API via Ajax

This thread is marked as Solved. jphonor still has a truncated image. please review and reopen ticket.

Hi all,
We are looking into the issue and will notify regarding the same if we find any.

Hey Ritesh,
Would it help if I provided the entire results via an attached file so you could test the script directly yourself? I’m thinking more in regards to the Base64 image content so you can see if I am passing the correct data to the API.

Justyn

Hi Justyn,
Yeah, that will help to debug the issue.

Ritesh,
If you could change the status from “solved”, I think I would get updates on changes. I’m not currently getting any emails when you update.

Thank you very much for you help and I hope the attached doc is useful. Let me know if there is anything I can provide you.

Attachment Link(s):

http://rtcamp.com/wp-content/uploads/rtMedia/topics/65448/2014/05/image-debugging.txt

Hi Justyn,
Thanks for the doc. We will look into it and will let you know regarding the same.

Ritesh,
I need to escalate this issue. We are in a critical situation to get this working.

Hi Justyn,

Sorry for delaying in this.

You are using base64 method, in that case you need to specify image type as jpeg/jpg or png or whatever the type of image. You need to change image_type to either jpeg or jpg in your case. Actually this thing was missed out from the developer doc, we will update it.

Ritesh,
Here’s my function for uploading:

function sendFiletoRTMedia(){	  
	var uploadToken = window.localStorage.getItem("satToken");  
	var imageData = window.localStorage.getItem("satImageObject");	  
	var uploadData = {  
	action 			: "rtmedia_api",  
	method			: "rtmedia_upload_media",  
	token 			: uploadToken,  
	rtmedia_file 		: imageData,  
	title			: "test from console",  
	context			: "profile",  
        image_type		: "image/jpg"  
}

Notice that image_type is set to image/jpg (I tested with image/jpeg as well). Both give me a success message, but the image is blank.

When I changed the image_type: “jpg” (omitting the “image/”), I got the error message “Image type missing” with a status code 140006.

Hi Justyn,

I tested it on our demo site -> http://demo.rtcamp.com/rtmedia/ with the same parameters as you had attached in the above file and file was uploaded successfully. I just changed token value and image_type to jpeg.

Can you please check it once on our demo site and confirm this.

You will get image_type missing message when value of image_type parameter is empty.

Also check with WordPress default theme and with other plugins disabled, just make sure that there isn’t any plugin conflict or theme issue.

Ritesh,
No luck. I turned off all plugins except the base needed for BuddyPress and RT Media, using the Default theme. Here’s the debug info:

Home URL http://dev.shareatalent.com
Site URL http://dev.shareatalent.com
PHP 5.3.24
MYSQL 5.0.96
WordPress 3.9.1
BuddyPress 2.0.1
rtMedia 3.6.14
OS Linux
Imagick ImageMagick 6.5.4-7 2012-05-07 Q16 OpenMP www.imagemagick.org
GD bundled (2.0.34 compatible)
[php.ini] post_max_size 33M
[php.ini] upload_max_filesize 32M
[php.ini] memory_limit 256M
Installed Plugins rtMedia for WordPress, BuddyPress and bbPress by rtCamp version 3.6.14,
BuddyPress by The BuddyPress Community version 2.0.1,
rtMedia Pro by rtCamp version 2.3.1
Theme Name BuddyPress Default
Theme Version 1.9
Author URL http://buddypress.org
Template Overrides plugins/buddypress-media/templates/media/album-gallery-item.php,
plugins/buddypress-media/templates/media/album-gallery.php,
plugins/buddypress-media/templates/media/album-single-edit.php,
plugins/buddypress-media/templates/media/media-gallery-item.php,
plugins/buddypress-media/templates/media/media-gallery.php,
plugins/buddypress-media/templates/media/media-single-edit.php,
plugins/buddypress-media/templates/media/media-single.php,
plugins/buddypress-media/templates/media/uploader.php
Total Albums 29
Total Photos 37


I’m going to build a completely fresh install on a subdomain and see if I can get it to work while I wait back to hear from you.

Thanks, Ritesh!

Just confirmed with a completely fresh installation of latest WordPress, BuddyPress, RT Media, and JSON API. Same results on my end. I get a successful upload message, but the image is blank on the site. Screenshot is attached.

Possible PHP version issues? I noticed that PHP 5.3.24 is installed on both my dev and the test build I just created.

Attachment Link(s):

http://rtcamp.com/wp-content/uploads/rtMedia/topics/65675/2014/05/testing-rtmedia.jpg

Ritesh,
Can you send us the config of the demo site. So we can compare our plugins and versions to your site.

Debug info of our demo site:

Home URL http://demo.rtcamp.com/rtmedia
Site URL http://demo.rtcamp.com/rtmedia
PHP 5.5.10-1+deb.sury.org~precise+1
MYSQL 5.6.15
WordPress 3.9
BuddyPress 2.0.1
rtMedia 3.6.14
OS Linux
Imagick ImageMagick 6.6.9-7 2014-03-06 Q16 www.imagemagick.org
GD 2.1.1-dev
[php.ini] post_max_size 200M
[php.ini] upload_max_filesize 200M
[php.ini] memory_limit 256M
Installed Plugins Akismet by Automattic version 3.0.0,
bbPress by The bbPress Community version 2.5.3,
rtMedia Instagram by rtCamp version 2.1.4,
rtMedia Photo Tagging by rtCamp version 2.2.4,
rtMedia for WordPress, BuddyPress and bbPress by rtCamp version 3.6.14,
BuddyPress by The BuddyPress Community version 2.0.1,
Contact Form 7 by Takayuki Miyoshi version 3.8,
Google Analytics for WordPress by Joost de Valk version 4.3.5,
Gravity Forms by rocketgenius version 1.7.9,
IJM Theme Switcher Bar by Iain J McCallum version 2.0,
MailChimp Newsletter Widget by Matthew Poer version 1.0,
MailChimp Widget by James Lafferty version 0.8.12,
myCRED by Gabriel S Merovingi version 1.4.4,
Ninja Forms by The WP Ninjas version 2.6.2,
Qr Code Adv by Branimir Ivanov version 1,
Quick Page/Post Redirect Plugin by Don Fischer version 5.0.6,
Rewrite Rules Inspector by Daniel Bachhuber, Automattic version 1.2.1,
rtAccount Login by $trik3r version 1.01,
Google Analytics plugin to track page scrolling by rtCamp version 1.0.0,
rtAntiSpam by rtcamp version 1.0,
rtMedia Pro by rtCamp version 2.3.1,
rtMedia Widgets by rtCamp version 1.0,
rtSocial by rtCamp, rahul286, rutwick, saurabhshukla, HarishChaudhari, faishal, 5um17, JoshuaAbenazer version 2.1.15,
WooCommerce by WooThemes version 2.1.8,
WordPress Importer by wordpressdotorg version 0.6.1
Theme Name InspireBook
Theme Version 1.2.2
Author URL https://rtcamp.com/
Template Overrides themes/pt-rtmedia/rtmedia/media/album-gallery-item.php,
themes/pt-rtmedia/rtmedia/media/album-gallery.php,
themes/pt-rtmedia/rtmedia/media/album-single-edit.php,
themes/pt-rtmedia/rtmedia/media/media-gallery-item.php,
themes/pt-rtmedia/rtmedia/media/media-gallery.php,
themes/pt-rtmedia/rtmedia/media/media-single-edit.php,
themes/pt-rtmedia/rtmedia/media/media-single.php,
plugins/buddypress-media/templates/media/uploader.php

Can you create an account for me on your site so that I can check the issue. My ID is [email protected]

Ritesh,
I just sent credentials. I see we’ve got different PHP versions running. I set you up as an admin.

I’m updating to PHP 5.4, but I found an issue that may be helpful. In the console, I’m now getting an HTML warning message:


Warning: file_put_contents(/home/content/62/10656162/tmp/test_from_console.image/jpg) [function.file-put-contents]: failed to open stream: No such file or directory in /home/content/62/10656162/html/dev/wp-content/plugins/buddypress-media/app/main/controllers/api/RTMediaJsonApi.php on line 962

Hi Justyn,
It is trying to locate directory ‘/home/content/62/10656162/tmp/test_from_console.image/jpg’ which is not exist. Change image type to image/jpg to jpg.

Hey Ritesh,
As I noted back a few posts ago, when I remove the ‘image/’, I get the status_Code:140006, image type missing response.

I think the API is failing to remove the ‘image/’ from the file name prior to storing the image, which is causing the upload to fail.

Hi Justyn,
Can you send SSH / FTP credentials to [email protected] so that I can debug the issue.