I have a strange isuue in Yii.
We are using Yii for webservice with Android and IOS. In the mobile there have video uploading page.
This is the code iam using in Yii to upload video:
$file_path_image = "";
$directory='images/Post';
$file_path_video = "";
$model = new TblCommunity();
if(isset($_FILES['video'])){
$file = $_FILES['video'];
print_r($file);
$videoID = $model->getRandomString();
$video_obj = new VideoUpload();
$result = array();
$video_result_temp = $video_obj->upload($file, $videoID, $directory);
$result = CJSON::decode($video_result_temp);
if(isset($result['status']) && $result['status'] == 'failed'){
$result['response'] = array();
$result['status']='failed';
$this->_sendResponse(201, CJSON::encode($result));
} else {
$file_path_video = Yii::app()->params['BASE_URL'].$result['Path'];
}
}
The above code will work for small size videos.
But when the mobile guys start to upload a big size or above 5MB , I didnt get any data in Yii.
Its wasting my a week full of time.
What is the reason for this strange behaviour?
All helps are appreciable.
When sending large size video , the Yii returns error as Undefined index 'video'.
There can be 2 reasons:
Model rules (max file size)
Php/Server settings (upload_max_filesize, post_max_size)
Did you check this already?
Related
I am working on an xamarin app that has images stored in an S3 bucket. The querying works correctly in xamarin when using the correctly constructed Url:
https:// + BucketName + path + ".jpg?AWSAccessKeyId=keycode&Expires=expireNumber&Signature=signatureCode"
When using
Image.Source = urlAddress (as the above format)
The image is loaded fine
Part of the apps pages have custom renderers with Images that need to be rendered via url address. We are updating the images via url at each os level. The iOS is working correctly using the following code:
using (var url = new NSUrl(uri))
using (var data = NSData.FromUrl(url))
if (data != null)
return UIImage.LoadFromData(data);
Which successfully gets the image from Url and updates it. However I am having major issues having it work on Android. I have tried the following area:
making a basic android url and setting the imageView with the following code. Which has been explained to not work here https://forums.xamarin.com/discussion/4323/image-from-url-in-imageview
Android.Net.Uri url = Android.Net.Uri.Parse(url);
imageView.SetImageURI(url);
On that same link using WebClient was suggested by user 'rmacias' to download the data via the url and parse the bytes to an android Bitmap.
private Bitmap GetImageBitmapFromUrl(string url){
Bitmap imageBitmap = null;
using (var webClient = new WebClient())
{
var imageBytes = webClient.DownloadData(url);
if (imageBytes != null && imageBytes.Length > 0)
{
imageBitmap = BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length);
}
}
return imageBitmap;}
This returns a 403 forbidden error. at the line var imageBytes = webClient.DownloadData(url)
However the same process is working in iOS, the string is already authenticated and I have set the authentication timeout for several minutes incase of slow load. I have also tiued the same url requesting method with the .Net.Http library.
It crashes at res = (HttpWebResponse)request.GetResponse(); with the same 403 Forbidden error.
I have tried multiple things with header authentications for the WebClient and Http client. It feels that its something specific about android requesting url data because the authentication in the url string works for the Xamarin images and in the ioS code.
I'm thinking there is something specific to android that I am missing? Help is much appreciated!
How about using HttpClient, which can leverage the platform specific HttpClientHandler's which Xamarin provides?
So something like:
// make sure to reuse your HttpClient instance, it is a shared resource
// using it in a using() and disposing it all the time, will leave
// sockets open and bog down the connection!
private static HttpClient _httpClient;
public async Task<byte[]> GetImageDataAsync(string url)
{
if (_httpClient == null)
{
// you could inject AndroidHttpClientHandler or NSUrlSessionHandler here...
_httpClient = new HttpClient();
// set headers etc...
}
var response = await _httpClient.GetAsync(url).ConfigureAwait(false);
if (!response.IsSuccessStatusCode)
return null;
var result = await response.Content.ReadAsByteArrayAsync().ConfigureAwait(false);
return result;
}
Then you can use this platform agnostically like:
var data = await GetImageDataAsync(url);
imageBitmap = BitmapFactory.DecodeByteArray(data, 0, data.Length);
on iOS
var data = await GetImageDataAsync(url);
var imageData = NSData.FromArray(data);
imageBitmap = UIImage.LoadFromData(imageData);
There are also nice libraries, such as FFImageLoading, which support this out of the box, with effects, loading of images in TableViews etc., which you can consider as an alternative.
I am a newbie in Unity3d and Parse.com.
I want to play online video that I store in Parse.com. However when I get an AbsoluteUri of parse file for play, It open video and just play for 1s then it auto close. What thing I did wrong ? see the code below
public void queryBundleWithName(){
var query = ParseObject.GetQuery ("AssetBundle").
WhereEqualTo("name", "Board");
query.FirstAsync().ContinueWith(t =>{
ParseObject relatedObjects = t.Result;
string name = relatedObjects.Get<string>("name");
//isFinish = true;
urlVideo = relatedObjects.Get<ParseFile>("video").Url.AbsoluteUri;
textResult.text = urlVideo;
Screen.orientation = ScreenOrientation.LandscapeLeft;
Handheld.PlayFullScreenMovie (urlVideo, Color.black, FullScreenMovieControlMode.CancelOnInput, FullScreenMovieScalingMode.AspectFill);
});
}
Thank for your help.
i am working on a Cakephp 2.x .. i am sending data from my android app to my Cakephp web app through HTTP Post and then saving into the database..
here is my code
public function message(){
$this->loadModel('Message');
if ($this->request->isPost()){
$json = $this->request->data('json');
$data = json_decode($json, TRUE);
foreach($data as $datas){
$mobileNo = $datas['mobileNo'];
$body = $datas['body'];
$type = $datas['type'];
$userId = $datas['idUser'];
$this->request->data['Message']['mobileNo'] = $mobileNo;
$this->request->data['Message']['body'] = $body;
$this->request->data['Message']['type'] = $type;
$this->request->data['Message']['User_id'] = $userId;
$this->request->data['Message']['dateTime'] = null;
$this->Message->save($this->request->data);
}
}
}
i am getting data successfully because when i print out the data
$mobileNo = $datas['mobileNo'];
it is successfully printing the number ... but dont know why it is throwing me errors on my android app and not saving the data into the database ... i think the problem is related to the Model 'Message'
You are missing to call $this->Message->create(); before the save because you're calling save() in a loop. See http://book.cakephp.org/2.0/en/models/saving-your-data.html#model-create-array-data-array
Also check your validation rules and if your android app fails, well, do you send a proper success or error status back to the android app?
Best would be to put the data processing into a model method and unit test that method.
This is my first time really getting my teeth into Air for Android so please forgive me if this issue has been covered already. If it has then I've been unable to find it.
So I have an application that loads and displays xml data.
In the app I've got code to check if wiFi or equivalent is available and if so then pull live xml file and if not then pull the local xml file that was packaged with the application.
The app works fine if I am pulling in the xml from the live url but not if pulling from local.
After doing some research I discovered that when pulling in local file then Air for Android works slightly differently. So I need to resolve the application directory.
I did this and still no joy.
After a bit more research I read some post's that said I should use fileStream()
Tried this and still nada :(
All the time whilst testing in Flash IDE it works as intended.
If I had any more hair left I would be pulling it out right now!
The local xml file is set in the "includes"
Sample code below I am using for testing
var subURL:String = "xml_feeds/myxmlfile.xml"
var fileStream:FileStream = new FileStream();
var file:File = File.applicationDirectory.resolvePath(subURL);
fileStream.addEventListener(Event.COMPLETE, processXMLData);
fileStream.openAsync(file, FileMode.READ);
MovieClip(parent).txStates.text = file.url+" - TRYING"
var prefsXML:XML = new XML()
function processXMLData(event:Event):void{
MovieClip(parent).txStates.text = file.url+" - OPEN"
prefsXML = XML(fileStream.readUTFBytes(fileStream.bytesAvailable));
var tempArr:Array = new Array();
var reportCount:Number = prefsXML.row.column.length()
for (var i = 0; i < reportCount; i++) {
var rName:String = prefsXML.row.column[i].#name.toString();
var rValue:String = prefsXML.row.column[i].toString();
var rTitle:String = prefsXML.row.column[i].#name.toString()
tempArr.push([rName, rValue, rTitle]);
}
showData()
fileStream.close();
}
Is there anything I've missed?
UPDATE: 21/08/12
No idea what is going on with this. Here is the code i now have to use in order to load in the local xml file. Seems rather long winded
function listing():void{
var folders:Array = new Array();
folders = File.applicationDirectory.getDirectoryListing();
for(var i:Number =0;i<folders.length;i++){
if(folders[i].isDirectory){
if(folders[i].name=="xml_feeds"){
var files:Array = new Array();
files = folders[i].getDirectoryListing();
for(var j:Number=0;j<files.length;j++){
if(files[j].name=="CTSection2.xml"){
fileStream.openAsync(files[j], FileMode.READ);
fileStream.addEventListener(Event.COMPLETE, processXMLData);
fileStream.addEventListener(IOErrorEvent.IO_ERROR, localXMLFailLoad);
}
}
}
}
}
}
Ok, I have an app I've been writing in Flash builder that makes several HTTPService requests to a server to gather some data about the user. In one view it goes and downloads a string from a server, it then splits the string using delimiter ":" and then adds the components to an array to populate a Spinnerlist. In the simulator this works great, if I package the app for iOS and install it on my iPhone - it works great. But when I try to run it to my Android device, it doesn't work. It acts as though it is working, it loads the view with the SpinnerList on it but the list is empty. I can't seem to figure it out.
Some things I've tried: the XML settings i have enabled the internet access to the android device, in fact, earlier in the app when the user logs in the phone make a very similar server call which works fine on all devices.
This issue has me completely dumbfounded, and help would be greatly appreciated!!
here is the code that makes the request and separates the data.
HttpService Request:
<mx:HTTPService id="CommonHTTP" url="http://dispatch.americantaxi.com:8080/AT/servlet/OnlineOrderServices?command=retrieveCustomerCommonPlaces&customerId={data.ID}" resultFormat="text"/>
Sorting code:
protected function button5_clickHandler(event:MouseEvent):void
{
PickUpType = "Common";
data.PickUpType = PickUpType;
var CommonDataString:String = new String(CommonHTTP.lastResult);
trace("String " + CommonDataString)
var Arr1:Array = [];
Arr1 = CommonDataString.split("|");
trace("arr1 length " + Arr1.length);
var ArrCount:Number = new Number(Arr1.length);
var Arr2:Array = [];
for (var i:Number = 0; i < (ArrCount - 1); i++) {
var currentSelect:String = new String(Arr1[i]);
Arr2 = currentSelect.split(":");
var currentName:String = new String(Arr2[1]);
trace("Add: " + currentName);
CommonPlacesArray.addItem(currentName);
}
data.CommonPlacesArray = CommonPlacesArray;
navigator.pushView(CommonPlaces, data);
}