How to reference a file (e.g. testaudio.mp3) from another file (e.g. index.html) in Alfresco - alfresco

I have a mp3 file in a folder called "audio" in Alfresco. I would like to have a link that points to that file in my index.html file which resides in another folder.
For example: <a href="pathToTheFile>test song 1</a>
How would I reference that file? I tried with href="/share/proxy/alfresco/api/node/content/workspace/SpacesStore/xxx-xxx-xxxxx/testMP3.mp3" and it does not work. Or is it even possible with Alfresco? I am using the web interface.
My apologies for not making myself clear. I am using Alfresco Explorer Community Edition for management, and the website I'm working on is based on Spring MVC and pulls content from index.html files in Alfresco.
Currently I need to use <embed> tags to include a mp3 file to index.html, and the mp3 file is also stored within the Alfresco repository but in a different folder.
How would I reference the mp3 file from the index.html file? The referencing has to work when the index.html is deployed to the client website, and currently the client website is referencing files in Alfresco in the following manner: <img src=/asset/xxxxxx-xx-xxx/test.png>(There is no asset folder in the Alfresco repository, and somehow that works...). But this does not work for my mp3 file...

To access alfresco content using the RESTful api, you should be querying this webscript: /alfresco/d/<d|a>/<workspace>/<store>/<nodeId>/<filename>
where :
d and a refer to direct / attached mode
<workspace>, <store> and <nodeId> reference your content nodeRef
<filename> a file name of your choice
So your URL should look something like this http://<host>:<port>/alfresco/d/d/workspace/SpacesStore/8444ad61-4734-40e3-b2d4-b8b1c81347fd/test.mp3
Note : Depending on the permission set on your node, you might need to attach an alf_ticket to the URL for an authenticated alfresco user. Please check this for further insights.

Related

How to retrieve asp.net media / resources based on logged in user?

I have an asp.net web api project using token based authentication. my app uploaded and retrieve images and I keep file path in table_myfiles along with the uploaded user ID.
I would like the user to access only the files he have uploaded, which I can identify from the table.
How to protect my resources to restrict access to only to the user based on table_myfile ? And not to anyone without logging in or direct link / path ?
I have been searching for any possible solution for a week now , I think I should implement a middleware to manage access. But I couldn’t find any resources on how to implement the same.
Currently my api shows all resources just by directly accessing the file path/link.
The simple apporach is to remove the vitural folder, or that folders from the web site folders. That way, no simple URL exists for any of the files.
So, for a user to get/see/use/download a file? You present say a listview or some kind of grid (or repeater) that displays and lists out the files.
Then, when they want to download or view a file?
You use response.write and stream the file down to the client side.
Remember, on the server, code behind uses 100% clean and correct windows file paths. For any web based URL, then that folder must be in a valid path of the web site. When they type in a valid URL, it eventually gets translated to that given folder in the site (or a external folder provided when you create a mapped "virtual" folder in IIS. However, if you don't provide that virtual folder, or the folder is NOT in the web site file/folder sets, then no valid URL's exist. However, that folder can be directly used and hit with code behind - any valid server path/folder name is allowed in code behind.
Because when streaming the file, you need path name, file name, AND ALSO the "mine" type. Thankfully, .net 4.5 or later has this ability.
so, from a database (table) I display the file names like this:
But, if you click on the preview image, that is a image button.
The code behind simply gets/grabs the file name from the database.
I then download (stream) the file to the browser side like this:
if (File.Exists(strInternalFullPath))
{
string strConType = MimeMapping.GetMimeMapping(strInternalFullPath);
binFile = File.ReadAllBytes(strInternalFullPath);
Response.ContentType = strConType;
Response.AppendHeader("Content-Disposition", "attachment; filename=" + Path.GetFileName(strWebUrl));
Response.BinaryWrite(binFile);
Response.End();
}
else
MyToast2(this, btnLink.ClientID.ToString, "File Not found", "We no longer have this file avaiable.");
so, this buttion behaves 100% like a link, but there are no existing URL's or path name that points to the files folder from a web based URL.
Remember:
Web based URLs - they auto map from the web site URL to a existing folder.
You can use server.MapPath("some url to file") to "translate" this to a internal file name.
Code based files:
In your .net code (code behind) ANY file name is a standard plane, jane file name that points to a file on the server.
so, once we have that file name from the database, you can steam the file as if the user clicked on a link. But you never have to expose the actual file name, or file path. And no such valid URL's exist on the web site, since you do NOT have that files folder in the web site folder hierarchy - but placed that folder outside of the web site.
As long as that folder is outside of the web folders, and as long as you don't setup a virtual folder that points to that folder outside the web folders?
Then code behind can STILL get/grab/see/use any file on the server. that code uses a full valid windows file name, - but the web site will have no mapping to such a folder - hence no valid URL's will exist or can be typed in.

Where to put the live-search-docs config file in all in one alfresco project?

I have been going through some blog posts that tell how to customize the live search . What is not clear to me is where should I place the live-search-docs.get.config.xml file in my all-in-one-share project so that it is bootstrapped and deployed in the correct location.
Please can some one advise where the file should be placed in my all-in-one alfresco project?
From the link below
https://www.bluefishgroup.com/insights/ecm/adding-metadata-fields-to-simple-search-and-live-search-with-alfresco-5/
they suggest the search query customization file to be placed under
These files can now be modified to add additional metadata fields as
needed. Once the files have been updated, they should be deployed to
the ‘extensions’ directory so that they will override the out of the
box configuration. If you are deploying your code as a custom AMP
file, the files should target the following directory:
tomcat/webapps/alfresco/WEB-INF/classes/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search
if my file needs to end up in the above path in my WAR, where exactly should I place the search file in my all-in-one alfresco project so that its deployed to the above folder? I would like this to be bootstrapped with my all in one project. I tried putting the file under src/main/resources/alfresco/site-webscripts with the remaining path for the file but that did not work.
Thanks
The easiest way is to create a copy of that file in:
my-all-in-one-project-platform-jar/src/main/resources/alfresco/extension/templates/webscripts/org/alfresco/slingshot/search/
where, of course, my-all-in-one-project-platform-jar must be substituted with the name that you have specified when the project was created with the all-in-one archetype.
The file in the extension subpath will override the corresponding OOTB files.
See Web scripts

GraphHopper offline routing using .osm.pbf file

I downloaded the .map file and display with Mapsforge. Now, I want to find route offline using GraphHopper.
Can anyone give me an example link?
What do I need to do for offline routing with GraphHopper and what files I need and where to put the file in a mobile directory?

Hide/encrypt or otherwise change path to mp4 file in drupal

I have video files (mp4's as I want people to be able to view them on ipads etc.) that I serve to users. However some of these videos are only available to users who have a certain number of user points. I have that working in that if a user doesn't have enough user points they can't view the node. All users have the same role (video viewer) and the problem is that it is possible for someone who has enough user points to view the node, grab the url of the video and then give it to someone who has the video viewer role but doesn't have enough user points and then that person can directly download that mp4.
Just looking for a way to limit access to the mp4 file if a user does not have access to the node or hide the path to the file somehow. I have the mp4's stored in a private file system but this hasn't solved the problem as the users have the same role.
I've got this (http://www.ioncube.com/html_encoder.php) working on static pages in my webspace (non drupal pages) but can't get it working in my drupal setup. When I include the php code in my node to include the php file it just gives me a blank page.
Many thanks
There's not much I could say about this that the Drupal documentation doesn't already.
http://drupal.org/documentation/modules/file#access
Managing file locations and access
When you create a file field, you can specify the sub-directory of the site's file system where uploaded files for this content type will be stored. The site's file system paths are defined on the File system page (Administer > Configuration > Media: File system).
You can also specify whether files are stored in a public directory or in a private file storage area. Files in the public directory can be accessed directly through the web server; when public files are listed, direct links to the files are used and anyone who knows a file's URL can download the file. Files in the private directory are not accessible directly through the web server; when private files are listed, the links are Drupal path requests. This adds to server load and download time, since Drupal must resolve the path for each file download request, but allows for access restrictions.
The best practice for public files is to store them in the multi-site directory like: sites/default/files
The default way to securely add a private directory for your files is to use a directory that can not be accessed directly by your web server, but can be accessed by Drupal. Ideally this directory should be located outside of your Drupal root folder.
The simple way to add a private directory for your files is to create a sub-directory under the public directory like: sites/default/files/private
When you specify the private directory in admin/config/media/file-system it will automatically create the sub-directory & create a simple .htaccess file with Deny from all. This stops Apache from serving files from this directory. Make sure that you test this by adding file to that directory and verifying that you can't browse there directly. If this isn't working, all files in this directory will be accessible to anyone who can guess the URL! Note that non-Apache web servers may need additional configuration to secure private file directories.
Accessing Private Files
Once configured, files stored in the private directory are inaccessible via a direct link; however, if Drupal constructs a link to the file, the file will be accessible to anyone who can see the link.
For example: you have created a new content type with a file field which stores files in your site's private file directory. Next you create a node from this new content type and attach two new files. When the node is published links to both attached files are visible and anyone who can view the node may download the files. Now, if you unpublish the node, all attached files become inaccessible for download even if you use the direct link to the files that worked when the node was published.
Re-publish the node, and disable the "display" checkbox for one of the files. Save the node. Now one file is accessible for public download and the other is not accessible--even if you have the direct URL for the file that is not listed you will not be able to download this file.
For finer grained control of who can see/download attached files you will need an additional access control module. You may write a module yourself, or use a contributed module such as Content Access.

How to deploy XML file with my web application?

I've written an ASP.net web application. In the interest of following the advice in "The Pragmatic Programmer" to put application logic in configuration, I wrote a large XML file that describes various business rules.
When I test the application on my local development workstation, I copy the file to c:\xxxxx\myfile.xml and then write the code to read the file from this location.
What is the correct way to deploy this xml file as part of my web application so that it gets read from the directory in which the web application is deployed?
Update: The XML file in question is for server-side configuration and should never be available for download to the end-user.
If you're not embedding this as a resource, you should:
Create a directory under which this file will reside.
Create the file and set its Build Action to Content.
Create a web.config file in that directory which forbids access to the directory so you don't expose your business rules to the Internet.
Add a setting in your application's main web.config that gives the path to this file relative to the root of the application, i.e. "~/MySecureFolder/MyBusinessRules.Xml".
Have some code that calls HttpServerUtility.MapPath Method to convert the value from the setting in web.config to a virtual path.
I don't know if this is what you want - Click on the XML file, then open the Property Window and find the "Build Action" property. Set the value to "Embedded Resources"
I think what you need to do is:
Add the XML file to your web application project in Visual Studio
Right click on the file and select 'Properties...'
Set the Build Action to 'Content' and Copy to Output Directory to 'Do not copy'
this will ensure that your XML file is deployed along with the rest of your web app.
If you want to make available your XML file from http requests to your server, you should
place it in your web publication folder.
This ASP instruction should help you to find your publication path:
Request.ServerVariables("APPL_PHYSICAL_PATH")

Resources