Is there an established way to retrieve the NID of a node based solely on the name of a file stored in an RDF repository?
i.e. sites/all/files/bitcache/file/1234567890abcdefghij => nid: 245
My goal: If a direct request is made for a file from the repository, I wish to rewrite the request to grab the appropriate node and display it, but I am having great difficulty figuring out how I can associate a NID with the file being requested, given no other information. I plan on using an .htaccess file to redirect the request to a PHP file which will do the lookup and spit out the correct node.
Much more info is available ... Thanks for your help.
Comments
Comment #1
Stupidscript CreditAttribution: Stupidscript commentedFor example:
Request: http://example.com/files/1234567890abcdefghij
Lookup: SELECT nid FROM {???} WHERE ???file??? = '1234567890abcdefghij'
Redirect: http://example.com/node/ . $nid
I'd like to note that I have been trying to work with the bitcache functions to resolve this, however they seem less than useful, in that they always either return an expanded string that uses the input directly, or nothing.
i.e.
$uri = "bitcache://a0f1d4b7b8471897cfe8ee368a21dbcf9617b7f8";
// uploaded file in bitcache/file/
$url = bitcache_resolve_uri($uri);
// produces: http://example.com/bitcache/a0f1d4b7b8471897cfe8ee368a21dbcf9617b7f8
// I expected a path to the file referenced by the fingerprint data, but that URI = 404
$url2 = bitcache_uri_to_id($url);
// produces nothing
// I expected to receive a NID or something similar
$data = file_get_contents($url);
// produces nothing, although the file actually contains significant content
// I expected binary output, as this sample is a PDF file
I know this is the RDF issues section, and my reasoning for placing this support request here is because the ONLY references in the database I can find that correlate to the actual files stored in the repository are contained in the {rdf_resources} table.
I can find no other similar data anywhere else.
Forgive me if this is not the correct place to ask.
Comment #2
Stupidscript CreditAttribution: Stupidscript commentedHere's how I did it:
.htaccess file in the 'file' directory grabs all requests and redirects to a PHP file containing this script segment:
Which gives me the two things I need for my links: the title and the url_alias:
The query relationships that get me there are:
Tweaks welcome.
Comment #3
smustgrave CreditAttribution: smustgrave at Mobomo commented