Is there anyway to like encrypt the url, I have a copy of a file that is stored somewhere else (var linkoffile = url where that file is saved) , and when a user requested for that file, I will make a copy of that url in another collection in mongodb and it has an expiration time , a time duration where that file will be available for that user, after that time , the copy of that url will be removed for that user (here I used TTL Indexes of mongodb). But Im thinking that since the url of that file is exposed in the frontend or in the client side, even if you removed the url copy in the mongodb , any user that already copied the url before it expired can still access the document, so im thinking of like encrypting the url so that user will not now where that file is coming.
Is there any way to achieve this? or is there any other solution that can also achieve what im planning to do?
Related
In one of my applications users have an option to upload the document. In that process I upload the document on the server in specific folder and save the path in database column. After process successfully saved the file path column looks like this:
C:\wwwroot\myapp\documents\Document 03072017.pdf
This path should give me direct access to this file. However, now I have administrator portal where they should be able to download the file. Each record in database is saved with unique key. The document above for example has key column with the value 09824982. When I show records on the screen for administrators, I would only show the icon for the document type. For example if document is pdf they will see pdf icon. If document does not exist for that record then it will be blank. My question is what is the best way to process the download int his case? Ideally I do not want to show the document path to the user. If they use dev tools I do not want to display that document root. Is there approach to download the file based on the key that I showed above? For example send ajax request with that key and then look up in the database record pull the path and download the document? I use JavaScript/JQuery with ColdFusion 10 and Oracle database. In the past I used ColdFusion to download/deliver files to the browser. This time I have single page app and CF is only used on the back end. If anyone can provide some example or suggestion please let me know.
I don't want to have a readable endpoint like this .com///something.jpeg
so one thing I could do is use hash (I'm using bcrypt) to mask whatever needed to be mask, but my question is will it have performances issue doing encrypting on the server side as I did not save the encrypted string into my db.
Here's how I will do it.
Saving
Bcrypt user_id, blog_post and filename and save my file into storage
Retrieving
Get all the related identifier from the db, bcrypt them and use the value to go get the endpoint of the file.
Am I doing it right?
I am creating user profiles (javascript webpage) that I store in a SQL database
Those profiles have a primary key ID that has auto increment feature.
When the user is creating its profile, he has to upload a file.
I'd like this file to be named id.ext, the problem is I upload the file through ajax during the creation of the profile, before the profile is saved in database as the user need to profide information about this file in order for the profile to be acceptable.
I could retried the max(id) in database and use it during my ajax upload but if 2 people are creating a profile at the same time : problem.
I've come up with other solutions :
naming the file bigrandom.ext and storing this name in database, but my boss absolutely wants id.ext
creating blank profile with an "uncomplete" flag + date at upload and run a batch each month to delete uncomplete entries in database
upload with id.ext, if the file already exist, name it id+1.ext and inform the webpage through json message in return of the POST query
As I think it's a common problem I guess there is some best practices about this, maybe even a feature from SQL I don't know.
A sequence object in the DBMS is far safer and more robust than taking your chances with MAX(id) +1. MS SQL Server has supported sequences since SQL Server 2012, and other database platforms have had them for an even longer time.
try adding a Guid field in the Table and create it when uploading the image. it will be unque always. U can save the image with this Guid as name.
I have to read a XML-file from a URL; then using JS I get the information that I need from the nodes. Since only I can access the URL every x minutes (and not every user of my App) I have to save that information in a database, perhaps in my own website. Later my users will access my site for getting access to the information.
How can I automate the whole process? At least 2 times per hour a function, program or class should be triggered for:
getting the XML-file
extracting the necessary data per JS
saving temporarily the data in an array or text file (necessary step??)
saving it into a DB
Any ideas ?
If you are using Jquery, you can get the data from the URL using the .get() method and then parse the xml using .parseXML method.
Check out these two links for examples:
.get() Method:
http://api.jquery.com/jQuery.get/
.parseXML() Method:
http://api.jquery.com/jQuery.parseXML/
I am building my first chrome extension, for that I want to have some predefined data at client browser.
I want that data be able to be edited by user by means of extension and save back the changes.
I first thought of using HTML5 local database or Indexed Database APIfor this.(Am I doing right?)
But I don't know how can I send this local database to client place in .crx..because the database will be with browser rather than extension.
How can I send data to client side browser by .crx and save the data on browser?
(I know its not right to save data on browser, but I can't save data back if I save data along with extension)
What other way I can use to implement the requirement?
can I use the same method if I want to use Indexed Database API instead?
My data is not simple key value pair but table kind of data.
I don't have any code for data access part, because I want to be sure before I can proceed
No, You can't send database file with ctx file. Simply You can't replace it on client side.
Actually you have two options:
1) save predefined data into your extension (in any extension file. save whole query or data as JSON) and after first run exec those query to local Database.
2) create web service from where you will get predefined data and save it to local DB.
For example (data.json):
[{"name":"name", "desc":"desc","some_column":"some value"},{"name":"name", "desc":"desc","some_column":"some value"}, ...]
In background.html:
var xhr = new XMLHttpRequest();
xhr.open('GET', chrome.extension.getURL('data.json'), false);
var dataStr = xhr.send(); //don't do this way. use asynch api :)
var data = JSON.parse(dataStr);
//connect to local database
for(var _item in data){
//create query to insert data into DB
//and exequte query
}