I have written a ac3 script to upload files to remote servers and it is working as expected with all the events.
From the server side script i am echoing some text according to the upload status and i want that status to be received in flash like response text in ajax.
Is it possible to receive response text from a server script after uploading a file.
Or it doesn't have to be a file upload yet i wanted to have the string echoed in the server side script as response text in flash.
If that is not possible like ajax or normal request and response then is there another ways of achieving that?
Here is the code which gets executed when upload is complete.
fr.addEventListener(Event.COMPLETE, function(e:Event): void
{
lblPer.text = 'Completed';
// ExternalInterface.call("uploadError",e.target.data);
})
where fr is FileReference object.
Try listening for DataEvent.UPLOAD_COMPLETE_DATA. That should have a data property on it that you can read the response from.
Related
I want to make a json file on the server, and then update this json file using flutter http method in my app. I will get user ID, and if the user ID is already present in json file on the server, I just update the content of that items in the json file for this user only. If the user does not exist I add a new block into my json file on the server.
To do this, I first created a json file on the server and passed its url to http.post or http.put, but my json file is still empty. This means I cannot write anything in my json file.
Why?
Could you please let me know how I can achieve this?
I have a url similar to https://www.nonexistentsite.com/fubar.json where fubar.json is a public json file which will download to your file system if you navigate to the url with your browser. I have a React web app where I want to read that file directly so as to display some of its data. I don't want to bother with any kind of a backend that would download the file to the apps file system so that it can read it. I want the React front end to read it directly in it's client side code with a fetch or an axios call or something like that. I'm familiar with the typical situation where I have a REST url like https://www.nonexistentsite.com/fubar which I can call and get the data. I'm failing to find info on how to handle this situation.
You could use Axios to load the data from the json file.
Example usage;
axios.get('https://www.nonexistentsite.com/fubar.json')
.then(jsoncontent => {
console.log(jsoncontent);
//do stuff with jsoncontent here
});
Maybe I'm misunderstanding your question, but I believe if you are just needing to fetch the json from a hosted file, you should be able to do so with axios.get(url)
I have an angular 2 project, how can I read and write to a JSON file on my server?
I can do what I want within my code itself bit I don't want to have to change my code, recompile and upload my website every time.
Any help? Examples are greatly appreciated
Angular can read the remote JSON file using the HTTP Client but it can't directly write to the remote file.
For writing, you can use a server side script such as PHP (supported by x10Hosting) to provide a url that allows Angular to post to (also using the HTTP Client), to update the JSON.
For example something like this PHP:
$data = json_decode('./data.json'); // decode the json
$data->something = $_POST['something']; // update the something property
file_put_contents('./data.json', json_encode($data)); // write back to data.json
I'm little confused about sending audio files from my client app (max. 10 sec of audio) into my server. The question is - which of the following options is the best?
From the client side save audio file into byte array and then convert it into Base64. After that send it in json request. On the server side, handle request in a Rest Api, decode Base64 and save it on the server. I was also wondering about making hash function of the audio file from the client side and send it also with the response and from the api compare these two hashes for integrity purposes (Missing packets or something).
Send an audio file as multipart form-data in json response and handle it in my Rest Api.
Simply saving file using FTP into my server.
Which option is the best? Or do you have any ideas?
Right now we have a web application which upload a file using multipart in spring . now we are converting it as a rest webservices with JSON to a mobile application. how to send file details to rest webservice controller using json.
Simple
This is stateless.
Send JSON similar to this:
{ "fileName" : "the file name",
"contents" : "the file contents"
}
Be sure to use JSON escaping of the file contents and the file name.
Not Great
This requires state (not a good thing for a rest controller).
Call1: Post to .../beginUpload
Description: starts a file upload.
Parameter:
filename
ReturnValue: some identifer (called FileId below).
Call2: Post to .../fileContents
Desciption: adds some contents to an already open file.
Call this one or more times until the file contents are fully transferred.
Parameters:
fileId, contents.
ReturnValue: success / failure
Call3: Post to .../endUpload
Description: ends a file upload.
Parameter:
fileId
ReturnValue: success / failure
Challenge: the rest server may need to timeout uploads that have not had a call to .../fileContents in x minutes.
Different
Have the mobile device send an email containing the file to be uploaded.
Implement something to monitor the emailbox to which the file upload emails are sent and do "the right stuff".