Track upload Progress AJAX+PHP S3 SDK - aws-sdk

I am trying to upload a folder into S3 form my local apache server using PHP sdk for S3.
// // Create a transfer object.
$manager = new \Aws\S3\Transfer($client, $source, $dest);
$manager->transfer();
this code is called from JS file via ajax.
Is there any way to know the upload progress in the javascript.

Related

serve html files with laravel

I have a laravel application that is working, but I need to display HTML files and assets (css and images), the web files were exported from another application built with python, so the HTML pages are very much (in hundreds), so I cannot be able to route each and every one of the pages.
I used the code below to route to the index page, but when I click on the link to another page, it returns 404
// Route::get('/index', function () {
// return file_get_contents(public_path() . '/pages/index.html');
// });
Please, how can I serve the pages, the folder is in the public folder of my laravel app.
I solved this by embedding it in an iframe tag in the blade file
What I did was, I hosted the web files generated from the python application on AWS S3 bucket, then I hosted the Laravel application on AWS Beanstalk, then I copy the S3 endpoint and embed it in the Laravel blade file using iframe, with this the web files are hidden under the authentication of the laravel app.

Write json data to local JSON file using only angular 7

I have a form on submit of the form I am receiving the json object after form submit. What I am trying is that I have a file data.json in my application folder in "/src/app/data.json". How can I write the data into the JSON file with Node.
Below is my code
Below is the code in my component.ts
savedatatojson(jsonobject){
// jsonobject is the json data
this.dataservice.savedata(jsonobject).subscribe(data => {
console.log(this.data)
})
}
Below is the code in my service file
public savedata(jsonobject):Observable<any>{
//code to be written
}
How do I save data to json file which I have obtained in my service file
You can't, web browsers don't have permissions to write to source files. There does exist a file system api, however this is non-standard and can only access a very limited location of files.
Instead you should either send the data to a database which later you can read and write to a file, or generate a file within the application which users could download for themselves to their own computer downloads folder. There is also the option to use serverless functions to update a remote file on a server, or for example a google sheet.

Load and Save JSON file react client-side only

I am building a simple editor-type application in react-redux, and I want to mimic the operation of downloading and uploading json files for saving and loading data - entirely client side. The server side does not need the data. Local storage may be too small, and it would be nice to provide the user the data in a portable file they could upload on a new machine. Is this even possible, and if so how?
Using a blob file.
You can set the content of a new file which is temp and local, then trigger a click event to download the file.
duplicate answer here and here

Load a JSON file at runtime

How do I load a local json file in react native project at runtime where the local file will be a variable name?
Example:
This works
var data = require("../../0001.json");
I want this to work:
var path = "../../0001.json";
var data = require(path);
I'm open to alternatives to require.
TLDR: How do I open a file at runtime in react native. Load local data files as required by the app?
If you are using webpack, you could simply use require.ensure. But since all you want to load is JSON data, why don't simply use file API to read the JSON into a stream and then use JSON.parse?

url request application storage directory AS3 Air

I have an application prepared in Action Script 3. There is a part related to requesting a file from application storage directory. However when I use following codes (xmlLoader part), program looks into app directory.
How can I make it look into application storage directory or may any other code alternatives be used for this request? Thanks.
var xmlLoader:URLLoader = new URLLoader();
xmlLoader.load(new URLRequest(Puzzleoriginalpath + ".xml"));
You can get the storage directory through
File.applicationStorageDirectory.nativePath
Then build your path:
File.applicationStorageDirectory.nativePath + "/examplepuzzle.xml"