How can i create a symlink(symbolic link) from an url in node js? - filesystems

I am trying to create a symlink by passing url in node js.
let link="https://image.png******"
fs.symlink(link,__dirname+"\\folder\\symnotificationfeed2",'file',(err)=>{
if(err){
console.log('errrr')
}else{
console.log("\nSymlink created\n");
console.log("Contents of the symlink created:");
}
})
With the help of above code I am able to create a symlink in my local system but I am not able to access it or read the file.
I am using windows OS.
Please,Help me with this.
Thanks

Symbolic links can only point to other filesystem paths, not URLs. In Windows, this would include UNC paths for SMB-based file access (e.g. \\server\share\image.jpg) – but still not URLs, neither HTTP nor any other kind.
In general, if a location cannot be opened with fs.open(), then it cannot be a symlink target either.

Related

How to download full directories off apache server via just a URL

I have searched all around and the only results I get are using wget or curl.
I would like to be able to download full directories being served on my apache server using just a URL. For example if I want to download the directory Contents, I would like to be able to do this: http://127.0.0.1/Contents. Instead, when I do this, I just get a page with all the files inside it instead of actually downloading the directory.
Is it because this is not possible? Or because i just need to configure it in apache2.conf ?
Worked it out, in order to download a folder/directory from a URL, compress the folder into a .zip file or anything similar to .zip, then call it in the URL: http://127.0.0.1/yourfolder.zip

fopen() file path in C

I have clone a git repository in C:/Repo. I am trying to open a file which lies in the git at some location ,for example, git/program/slm/error.txt. I am using fopen() API in C language to open the file and the filepath I am specifying is "C:/Repo/git/program/slm/error.txt". The program seems to be working while providing the above mentioned path. But,I want to make this program generic so that it can work on other systems as well as in other systems it is not necessary that the git will be cloned in C:/Repo only,this is local to my system. git/program/slm/error.txt is the relative path and will be common for all the system.
Can anyone please help me how what filepathname should I provide to make it generic so that it works on all the systems?
Take your repository path as commandline argument and then when you want to access the file append the repository path and the relative path that you want to access.

CakePHP Routing Slugs, detect Extension?

In my 2.X app we're detecting which Tenant is using the system via a Slug in the URL, ie:
app/[tenant_slug]/[controller]/[action]
The issue however is that when the users browser requests for some static file our server doesn't have, such as:
app/apple-touch-icon-76x76.png
Cake takes 'apple-touch-icon-76x76' as the tenant_slug - so then our server has to determine that no, it doesn't have that slug and then throw back a Not Found error.
I have the following matching criteria on the route:
$validTenant = '[a-zA-Z0-9-_]+';
And I also have the following enabled:
CakePlugin::routes();
What is the correct way of handling this so the router knows that if a static resource is requested (ie: file ending in .js, .css, .png etc), it shouldn't use the file name as a slug? Or, should I have my code that looks up the tenant_slug (TenantAuthorizeComponent) handling the case where there is a file extension?
I would handle this at the webserver level, if possible, do not even let php slow down your static files requests - for example for nginx I pass just php files into the interpreter using this statement in mysite.vhost.conf:
location ~ \.php$ {
fastcgi_pass php;
}

why does apache forbid access via symbolic links?

I am trying to install typo3 as per the instructions but I have a bit of a puzzle to solve.
It seems apache denies access to any files I try to access via any symbolic link in the site root directory. I have changed permissions from SymLinksIfOwnerMatch to FollowSymLinks and no joy.
I'm working on mac OSX (SL) and installing in my user's "Sites" directory. I can access any files in this CMS directory via the web browser just not anything through symbolic links.
I hope konsolenfreddy's comment was helpful already. I am trying to round things up here:
First check if the symlinks work from terminal and/or the filesystem in general.
Also, if you use absolute paths, the whole path from root to the file in question must be readable by the Apache user. *
If yes, check if the AllowOverride option is set for your webserver (or if applyable for the virtual host) For debugging you can set AllowOverride All in either apache2.conf, httpd.conf or in sites-available/default
If yes, check if FollowSymlinks is aktivated in any of the files responsible for your webroot, starting with apache2 working yourself down to the .htaccess files.
Try changing file permissions on the symlink file and the target directory (or files)
Try creating your own symlink and see what happens when you call it in the browser.
* Check this answer at askubuntu.com for more hints.
Ok I eventually solved it. In OSX the final file that governs access of sites installed in user directories is the last Include line in the apache2/conf/extra/httpd-userdir.conffile. Once I changed that my problems went away.
Thanks to all the people that replied my questions.

Beginner servlet deployment question: how to make third-party library access files in .war?

I get "Error opening ... file ... (No such file or directory)". However I do not control the file access - a third-party library is trying to open a file in the .war.
It works fine when using an open directory structure on my own computer.
My question is: is normal file access supposed to work within a .war? If not, should I just deploy a directory instead of a .war? Or is there a better way?
Am using glassfish.
.war file should be unpacked by your (application) server, so your third-party lib should operate with files from unpacked .war.

Resources