Objective-C: Reach a file on samba url - objective-c

I have a mapped samba network drive in Finder (for example "smb://192.168.15.119/public/ptest/test.rtf") and would like to copy a file from that drive to my desktop.
Do you guys know how would one go about achieving this? It's not mandatory to connect to that url through the mapped drive, if you have a solution that simply takes that url and copies the file from it, that's totally OK too.
EDIT: Based on Bastian's answer, the solution was to use NSFileManager's copyItemAtPath method with the source path being:
NSString *sourcePathx1 = [NSString stringWithFormat:#"/Volumes/public/ptest/test.rtf"];

when you connect to a network drive finder will mount it to /Volumes ... you can then access the share over this mountpoint.
If the share is not connected you can connect it by executing
mount_smbfs //host/share /some/temp/folder
If you want to access the file directly you would need some kind of samba library like http://nicolas.brodu.numerimoire.net/common/programmation/libsmb/archived_site/index.html but I don't know any active one.

Related

How to get local sync folder of one drive sync?

I have installed OneDrive on my local machine. Is there any way to get root folder/sync path of one drive ? I am looking for a programmatic way to fetch the root folder of one drive. Is there any API or interfaces through which I can access these details ? I want this API or interface for MacOS platform.
the information is in the registry.
Find the key HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts, you'll see your accounts as sub-keys. In them, look for the string value named UserFolder.

TrueCrypt mounting drive on network

My question is related to TrueCrypt drive created on a server. I want to mount this drive on few computers on network with write access. In order to do so, I installed TrueCrypt on a network computer and mounted the drive.
Problem
It mounts the drive after asking the password but triggers write error. In other words, it is read only.
What I have tried so far
I have looked in the documentation at truecrypt.com and it shows there are two methods of mounting
TrueCrypt Mounted Drive (Mounts drive on a local computer with read only access)
Unmounted Drive (Drive is mounted on the server and shared across the network)
What I want
Option 2 seems to be solving the problem with exception to it doesn't ask for password. It is same as any shared folder on network which makes it less secure. So is it possible to to mount drive on network with write access but after authenticating with TrueCrypt login credentials.
Any help will be greatly appreciated.
Based on what I have read (I haven't tried it myself) when you download the truecrypt file to your local machine, you should be able to mount it there and would be prompted for password. Once mounted, you should be able to write to or modify to your hearts content and then save to the encrypted volume you local machine. You will not be able to save the changes into the original server-based volume as that file is 'read only'. However, you should be able to save your modified volume to the server under a different file name.
What I did:
mounted the TrueCrypt Drive and a TrueCrypt-Container with VeraCrypt
created a windows (samba) and mac (afp) share of the drive and container with a password in the share settings (whatever software you use)
Mounting the container prevented it from being overwritten from some one else opening the container directly.

Access error uploading file using winsp

I am trying to upload two files to a webserver so my teacher can see it. I am using winsp since my filezila doesnt work. But for some reason it is telling me that i don't have access to that page. Can anyone tell me why is it doing that.Here is a picture of my screen.
I am just not understanding why it is telling me that i don't have to access it.
If I had to take a guess, that public_html folder is your public directory where you should put things that anybody can get to (like through a browser). You have your files outside of that directory, so your page can't access them.
edit:
It's an educated guess, as I have seen a fair amount of server configurations that name the public web folder as such (other common names are "www" and "httpdocs")
Problem definitly isn't in code. There is error while uploading files. Can you connect to FTP regulary? If you can. Look for Active or Passive file transfer to FTP. Also if you can upload files, files must be in public_html folder to be visible from browser.
Active or passive
First read Neal comment.
second, you should probably copy the files into the /public_html folder, instead of the / (root) folder.

Resolving a remote $HOME directory via FTP/SFTP

In Objective-C, NSString has a method called
stringByExpandingTildeInPath
This method will take a string like "~/Documents" and resolve it to "/Users/Nick/Documents". The "~" tilde is resolved to the home directory of the current user of the machine the program is running on.
Now my question is this... I am writing a little FTP/SFTP utility using Cocoa and Objective-C. How could I resolve a tilde (~) path on remote machine via FTP/SFTP?
For example. A user wants to upload a file to
sftp://remote-host.com:~/
If remote-host.com is a Linux or OSX server, then this path is totally valid. However uploading a file only works when I specify the absolute path. I'm not sure if this is a limitation of the framework I'm using, ConnectionKit, or if this is something that I need to manually implement. I'm ok with the latter but, any suggestions on how?
You could try just removing the "~/" (and use the rest as a relative path) - generally the server should put you in the user's home directory by default when you connect.

VB.Net File.Copy/File.Move with different credentials

Ideally I'd like to be able to copy/move between an accessible folder on my local drive and a network share that I don't have permission to access (but the application would).
I am using impersonation to give me access to the files in the network share but using System.IO File.Move or File.Copy forces me to use the same credentials for each location. Is there a way around this?
What I believe you could do is something like this.
Do the impersonation to allow the selection of files. Copy the files to a location that the app can get to.
Stop the impersonation then have the application copy the file from the temp location to the desired end result.
We have done this before in our applications, it isn't elegant, but it works perfectly!
We've done something similar to what Mitchel Sellers is doing, except that we don't have a location that both identities can read from. We are reading blocks of data into memory using the local context and writing them out while impersonating the remote user.