I'm developing a web app using ReactJS and trying to create a txt file with a number in it on the local storage, c:\temp for example.
Is it possible to do it without keep asking the user for his approval (dialog)?
Thanks
localStorage is a browser API and not an arbitrary file on the user's disk. If you are going to use it, then there is a handy React hook for it.
You can't write to arbitrary files on the user's disk, although you can generate a download from in-memory data. This may be saved to the user's download folder or may prompt a SaveAs dialog (you can't control which).
If you want to store data on the server then you can make HTTP requests to it (i.e. use Ajax) and write a web service to process those requests.
Related
How can I understand uploaded files are permanently stored in the website's server?
For example, how can I understand when I uploaded my PDF file to this website (https://smallpdf.com/pdf-to-jpg) whether its also saves my file to its server?
If you are referring to a third party server that you have no control over there is no programmatic way of determining if they are in fact storing your pdfs permanently.
They might have a Terms and Conditions page where they set out the terms and conditions of using their service.
Alternatively if it concerns you try to find a site that makes it clear that they do not store your files permanently.
Currently, I have a PHP app running on Heroku using a Postgresql database. I want my users to be able to upload an image to a folder on my dropbox, and store other information (in this case, product information such as price, title, weight, location of the image on dropbox) on my database.
Right now, I'm using a file input inside an HTML form to submit the image by posting the whole form to my server (including the image), and then I use cURL to send the image to dropbox and wait for the response to succeed. On success, I create my database record that has the other information I mentioned earlier.
This works well for small files, but Heroku has a 30 second timeout that I can't change. For large files, the whole file uploads to the server, and then it uploads to dropbox. These two upload operations are time-intensive and takes more time than the timeout allows.
I had the idea of sending the file to dropbox using javascript (jQuery ajax commands specifically) so that it's handled by the client, and then POSTing to my server on success, but I'm worried about how secure that is since I would need to have my own authorization tokens in the source code that the client can view.
Is there any way for PHP to send a file from the client to an external URL without it touching the server? How do I do this securely?
This sounds like a good fit for the Dropbox API /2/files/get_temporary_upload_link endpoint.
You can call that on your server to retrieve the temporary upload link, and then pass that link down to the browser. You can then have some JavaScript code perform the upload directly from the browser using that link.
Since only the /2/files/get_temporary_upload_link endpoint call requires your Dropbox access token (whereas the temporary upload link itself doesn't), you can keep your access token secret on the server only, without exposing it to the client. And since the upload happens directly from the browser to the Dropbox servers, you don't have to pass the file data through your own server, avoiding the timeout issue.
I have a web page that usually suppose to work offline.(without internet connection).
Once a while it's need to connect to the web and grab some data to be used offline.
I'm searching for a way to store the data locally while it connected and still have an access to the data offline.
I checked local storage and the FileSystem-API but both are follows the Same Origin Policy.
Any suggestion will be appreciate
When I was creating offline application to sync with online version I had some JSON file with required information instead of LocalStorage.
Work flow:
User requests new files to be generated (a.k.a. sync with server) using some online interface.
Generate JSON file with needed data and save it along offline files.
User downloads new files and replaces it with old ones.
Offline JS reads JSON file and gets all information.
We were using some JAVA installer (launch4j to generate .jar files and IzPack to make installer)
I'm developing web application using parse.com where news content may have 20 images. what is best place to store images to avoid consequences in the future, like overloading database performance cost and such
1) store in NOSQL object type database
2) store in folder and save path pointers in NOSQL
what are pros and cons going each way?
Parse isn't a great choice for a content hosting provider because you will be pressing on the storage cap, not to mention limitations on bandwidth usage.
Use Parse as a general-purpose backend for user authentication and app data, then host the images on another service such as AWS Simple Storage Service (S3) and reference those resources using cloud code web hooks. In case you're wondering, Parse actually uses Amazon to host all of their infrastructure.
Another option could be to access the images directly using AWS API Gateway. Once you have the images stored in S3, you will be able to automatically create native client APIs for your project.
When you upload a file, it will be stored on the disk (that is how Parse works). In your database, you only store only a link to that file. Generally, your images will not necessarily be stored in one location or server. For the sake of scalability, you want to take advantage of Content Delivery Networks (CDNs) which could replicate your images to multiple servers across the world. Now no matter where your image is stored, you should be able to access it anywhere simply via a single link stored in your database.
You can store the path to the images within the database, but you want to store the actual images on S3 and access them via Cloudfront (CDN).
You can setup cloudfront in front of your S3 bucket and this will allow all your images to be accessed via AWS' CDN.
I have a html5 app online that I am converting to a windows 8 store application.
It has a saving feature where an encrypted string is put into localStorage and deycrpted server side so that the user will have difficulty in cheating to get achievements.
However, I can't use the server in a windows store app because of the AJAX restrictions. So if I saved the savegame as plain text, would the localStorage variable be accessible by the user?
As #SLacks mentioned, anything stored on the file system is available to the user. You can, however, encrypt the data before it goes to the file system. If you write yourself a local storage controller to handler reading and writing, then you can access the filesystem through this boundary such that the rest of your code will not know that the files are encrypted.