+ Start a Discussion
Sami ShakithSami Shakith 

Can we specify the distionation(directory) for file to download in APEX class?

Hi all,

I need to download a document in specified distination. How can i achive this? Please anyone help me.
srlawr uksrlawr uk
Do you mean so when a user clicks a file link on a Visualforce page, you change the destination directory on the users computer that it is sent to?

If so - I'm afraid that is simply not possible. It is the clients browser which determines where downloaded files are saved, obviously it would be wildly confusing, and an incredible security issue if the supplying website could change where that file went. You could send them off to system folders, or hide malicious code all over someones HDD!

The only way to set the download destination is in your browser configuration. I'm afraid I have never heard in all my years of development a way to do that from the browser :(

Sami ShakithSami Shakith

Thank you for your reply.

It is definitely possible I think so. In DataLoader we have one option like "choose a target for extraction"  with a browser button. That functionality i want to bring inside VF page. Cant we implement like that?
srlawr uksrlawr uk
hmm. Well, yes... Do you mean Dataloader the application? If so, I guess that's true - but that's a standalone application so it's just written up like that, not in Apex, but in C or Java or some other application programming language. It's not run in a browser, or within Salesforce - it's just a piece of software.

If you mean Dataloader.io, "Add Destination Folder" is just for FTP or Cloud storage solutions (like dropbox)

The only way forward I could see to do this would be to try to write an old school style Applet (do they even exist any more?) or use Flash to write up a piece of "file download" software that facilitated the pick-a-folder dialogue box, and then house that somewhere on the internet, and embed that in a Visualforce page using Canvas.... (but that is honestly a joke answer, please don't try to do that!!)
Sami ShakithSami Shakith
That is not a smart answer hmm :(
srlawr uksrlawr uk
sorry dude.. whether I'm smart or not, it simply can't be done! good luck