How to store physical file location of files in MYSQL for a java EE web application? - mysql

I have three projects in eclipse for a cloud web application where the user can login and should be able to store files.
Front end(servlets/html/jsp),
Middleware(ejb's),
Backend(MYSQL server)
There is already a working login form connected to the database that authenticates users.
From my understanding, BLOB is not advised and i should be storing the physical file location instead.
I need to store the following information about each file:
file-name,
file-type,
physical-file-location,
webcloud-location
Ideally the user should be able to have access to other users directories if given permission.
So is that achieved in the same manner as implementing a login table that holds user credentials?
How exactly can a user download a file if the database only stores the location of the file?

Where to store.
You are indeed correct that it's advisable to store merely the file location in the database instead of the file itself. The usual practice is to use a unique hashed name when storing the file in the cloud while saving both the unique hash and the original file name in the database.
Sharing
In web applications, user directories aren't the same as user directories on linux. In a web app, they are virtual. What you need is a sharing table that links file ids with user id or group ids.
How to download
This is simply a matter of giving a link to the file as stored on the web cloud. If you have used a hashed name as mentioned above the file name is not guessable by others + you avoid the hassle of writing long lines of code to fetch the file from the cloud to the servlet container and pass through it's content to the user.

Related

Can the OneNote API copy a notebook or section from one user to another user in Office 365

I'm trying to copy section of a notebook, or even notebook itself, from a notebook in one user's OneDrive to another user's notebook in their OneDrive. The user I'm logged in as has permissions to read and write both notebooks. I'm getting the error response:
message=The specified resource ID does not exist.
#api.url=http://aka.ms/onenote-errors#C20102
code=20102
Where the path I'm using is of the form https://www.onenote.com/api/v1.0/users/{id}/notes/sections/{id}/copyToNotebook where the ids in that are for the source section.
which is presumably because the id in the post request represents a notebook under a different user.
If I was copying to a SharePoint site or group then the post request can have additional ids to identify that, so it be logical if there was a argument to identify the user to copy to.
Copying works perfectly when both notebooks are within the same user's OneDrive.
Is there any way of doing it between users in Office 365 OneDrive?
Yes, you can copy a section from one notebook to another user's notebook, as long as you have write permission to that user's notebook (or a notebook under another site).
In you scenario, the destination/post body has to contain the ID to the notebook, as well as the siteCollectionId and siteId, or the groupId of the site where the notebook is stored. (Checkout the message body format here). If you want to copy the section to another user's notebook, you will need the siteCollectionId and siteId of that user's OneDrive for Business; if you want to copy it to a notebook stored in a site, you will need the IDs for that site.
The reason you need those extra IDs is because by default the copy API will consider the destination notebook is stored in your OneDrive for Business. By specifying those IDs you tell the API that the destination is in another location. I'm assuming you didn't provide those IDs that you got the error.
You get get more information about obtaining the siteCollectionId and siteId here.

Report subscription rights to write file

I've done an experiment by specifying the path to be at my local drive and filled up my own username and password, ended up it hitting exception related to no access right.
Second experiment I've tested by sharing the folder at my local drive to everyone within the domain, and this time filled up using another username that have different SSRS role and it worked smoothly.
The role that I have was Browser and Publisher which should be sufficient. What is exactly mean by Credentials used to access the file share?

Where is the JSON credentials file for Ansible provision of Google Compute Engine?

I follow this guide http://docs.ansible.com/ansible/gce_module.html
And it indicates that credentials_file in JSON format could be used instead of the deprecated pem_file. Where can I get this credentials file?
Go to the Developers Console Credentials page.
From the project drop-down, select your project.
On the Credentials page, select the Create credentials drop-down, then select Service account key.
From the Service account drop-down, select an existing serivce account or create a new one.
For Key type, select the JSON key option, then select Create. The file automatically downloads to your computer.
Put the *.json file you just downloaded in a directory of your choosing. This directory must be private (you can't let anyone get access to this), but accessible to your web server code.
Set the environment variable to the path of the JSON file downloaded.
https://developers.google.com/identity/protocols/application-default-credentials#howtheywork

How can I know or construct the permanent url to a given file

We have an internal application that owns the folders for a given topic; topic subscribers are added as collaborators via the api. When a message to the topic contains an attachment, we upload it to the folder, where is can be accessed by the topic subscribers via a link we show in the rendered message.
The problem we have is partially an organizational issue:
Our users are restricted to shared links of a maximum time frame
This application uses a generic account from which it shares out these files, but there's no way to exclude it from the policy of shared links expiration
Our idea was to get the file url (eg. https://acme.app.box.com/files/0/f/689840703/1/f_17027007623 ) and display that link instead of a shared collaboration. It's not obvious from the documentation how to do so ...
Assuming the URL format doesn't change, you can template it as:
https://acme.app.box.com/files/0/f/$FolderId/1/f_$FileId
$FolderId is already known to you because you're programmatically uploading files to that folder.
$FileId can be derived from the File object that's returned to you as a result of the upload.

html5 localstorage accessiblity

In html5 if I create an new local storage key called mykey from a website www.a.com, will I be able to access mykey from another site, say www.b.com ?
Can any website access the key/value pairs created by other website? Please explain in detail. Even links will do fine.
I created two jsp files both of them using the same local storage and deployed them in jboss as different files. Now both the domains i.e localhost:8080/store1/local_storage.jsp and localhost:8080/store2/local_storage1.jsp are able to access the same key/value pair. How is that possible?
No.
Just like cookies are these objects only accessible from the domain that created them, for security reasons.
If you want to pass data from one domain to another I can recommend a form that posts to another site or put the data in a query string :)