+ Start a Discussion
atlantisatlantis 

upload file to SF then move to intranet file server

Hi,

 

I have an intersting  task. As we know sf provids uploading document function.

 

we want to mock this function. Supposing user logins to SF and select file from local matchine (in the intranet network) to upload, after the save button is clicked, instead of uploading file to SF, the file, in fact, is moved from local matchine to another file server(in the same domain  in intranet network).

 

in addition, user can click the link in the document record to view the file's content.

 

Any guys have any ideas to make this happen?

 

I am planning to run an web service to move files in the intranet, and expose the function to SF.

 

Is it available?

 

Thanks

SatgurSatgur

Well, there are few options that we have exercised for a similar problem.

 

1. S-control/Javascript on the page

 

     use Form action to do a Http "post" & send the file to an external server (http URL).
     Receive the response of post and external server should provide a Unique "Doc Id". We store the DocId in a custom object in SFDC which corresponds to the document saved externally.                   
  

    In order to view the document content, make a web service call to external server passing the "DocId" which was stored in SFDC custom object.

 

 

2. Now VF provides a file tag -

 

    a. Create a VF page with File upload tag.
    b. Select the file to upload and post webpage to external server.
    c.. when the file is saved at external server then We will save document id in a custom object of SF.
    d. We can use same Id to pass it to webservice and reterieve documents.

 

 

Hope this helps.

 

We had used approach #1 for integrating with an external document management server last year when we did not have support in full support VF. Hence providing second option where we can leverage VF capability.

 

 

Regards

Satgur

atlantisatlantis

, thanks for your solutions. they are great.

 

Regarding approach 2, could you give me some clues how to post webpage to the external server?

 

In addtion, can webservice pass file(any type) to SF? I thought some pdf or jpg cannot be passed via webservices.

PamSalesforcePamSalesforce

Hi,

 

I have created an InboundEmailHandler class which gets the pdf attachment from email and relates it to the custom object.

I now need to transfer it on a external server.

Can some one help me with this.

 

Thanks,

Cool_DevloperCool_Devloper

Hello Atlantis,

 

Did you get a solution for this?

 

Satgur,

 

Can you please help by providing a lil info on how can this be achieved as described by you?

 

Many Thanks,

Cool_D

atlantisatlantis

Hi Satgur,

 

I choose approach#2, however I didn't find apex code which can post webpage to external server.

Therefore, I use javascript in VF page.

 

Once user click a button in VF Page, the javascript behind the button is called and a window is pop-up.

In the window, we put extenal server url in it. Then it will post request to java web server where we can store uploaded file. When the file is uploaded into Oracle, the java appliaction will invoke SF web service to store the file name into SF.

 

In addition, we can use SF id to retreive the file in the external server(Oracle).

 

One limitation is that only laptop in the intranet network can access the java application.

As most of the SF users in our company will not logon SF outside intranet network. this will not affect them.

 

 

Cool_DevloperCool_Devloper

Okay, i have a little different scenario!

 

I want to send the file to an FTP server within the company network. Can i achieve this functionality in a similar way?

 

Or is there any other way of doing the same?

 

Many Thanks,

Cool_D

atlantisatlantis
yes, you can do it same way. However, instead storing file into Database, you can send the file to ftp server.
Cool_DevloperCool_Devloper

Thanks atlantis, that really helps!!

 

One more query i have, how do you exactly do this - "In the window, we put extenal server url in it. "

 

Also, what exactly happens when you do this? Is the file just transferred from local desktop to the server over the wire?

 

Will it work if instead of a local file, I am sending an attachment link (already existing in salesforce) to the server?

 

Your help has been gr8!!

 

Thanks,

Cool_D

atlantisatlantis

Hi,

 

#1. I am not sure if you are familiar with js. i have pasted my jscode in my VF page below.

 

================================

<script type="text/javascript">
    var curPopupWindow = null;
    
    function closePopup()
    {
        if (curPopupWindow != null)
        {
            if (!curPopupWindow.closed)
            {
                try {
                    curPopupWindow.close();
                } catch(ex) {
                 // This Exception code is to deal with IE issues checking
                 // The window closed property
                }
            }
            curPopupWindow = null;
            self.history.go(0);
        }
    }
   
   
    function doFileStorage(opt)
    {
        var s = '{!SessionId}';
        var u = '{!$Api.Enterprise_Server_URL_160}';
        var i = '{!doc.Id}';   

        //the application url you need request and the arguments that application needs     
        var q = 'http://jptky840unx.jp.fid-intl.com:16080/file?SfSID='+s+'&SfURL='+u+'&OPT='+opt+'&DocID='+i;
       

        // 1 for upload, 2 for download

        if (opt == 1)
        {
            var t = (screen.height - 400) / 2;
            var l = (screen.width - 600) / 2;

            // this statement is used to pop-up window
            curPopupWindow = window.open(q,'','height=400,width=600,top='+t+',left='+l+',toolbar=no,menubar=no,scrollbars=no,resizable=no,location=no,status=no');
        }

        else if (opt == 2)
        {
            window.location.href = q;
        }
    }  
   
</script>

...

<apex:commandButton value="Attach File" onclick="doFileStorage(1)" action="{!attachFile}"  />

#2. whatever you use to make the application in your interanet, the application will pick up the files user selected in local driver or anywhere they can access in the form of "filestream". Then the application can do the next step as you need.

 

#3. the you wanna send the attachement link in SF to the application. I think it should also work.

You need to use the attachment id and SF webservice to retrieve the document in SF.

Then put it to the ftp server.

 

Anyway, if the file is on the SF already, i dont think my solution is the best one.

Maybe you should think about web services or outbounding message.

 

Hope it is helpful for you.

 

Best regards,

Atlantis

Cool_DevloperCool_Devloper

 

Thanks a ton Atlantis for the help!!

 

I could understand most of the code but I need some help with the below-

 

var s = '{!SessionId}'; var u = '{!$Api.Enterprise_Server_URL_160}'; var i = '{!doc.Id}'; //the application url you need request and the arguments that application needs var q = 'http://jptky840unx.jp.fid-intl.com:16080/file?SfSID='+s+'&SfURL='+u+'&OPT='+opt+'&DocID='+i;

 

 

Can you please tell me what this URL is doing and what is the "DocId" ? I am not able to understand, that how the file is being linked in this URL :(

 

Also, the size of attachments in this case is huge, so i cannot look at webservices :(

 

Appreciate your kind help!!

Cool_D

Message Edited by Cool_Devloper on 11-12-2009 04:37 AM
ipsfadminipsfadmin

Hi!

 

Did you develop that? Is it worked?  I ta to develop something similar, I have to send/receive .csv files wie fithout using Appex Data loader and sending the file via ftp.

 

Thanks & Regards, 

 

 

atlantisatlantis

What i did is to send request to a web app inside my company, and then let the web app upload file from user's local computer and save the file into a database. Finally, the web app will call Force.com API to update SF records.

 

 

In addtion, I am going to develop another app samiliar s you need.

I will retrieve records from Force.com and send them to FTP or Database.

 

Are you going to use Apex Data loader manully or write code using its jar file? 

Also,I am interested in what type of app you are going to develop, web app or desktop?

 

 

Best  regards,

Atlantis

PamSalesforcePamSalesforce

Hi,

 

The project was dropped so never worked on it further.Do keep posted if you find anything regarding this.

 

Cheers,

PamSalesforcePamSalesforce

Hi Atalantis,

 

I am looking for a way to write apex code to generate a file and store it on an ftp server. Have you worked on something similar.

 Can you please help me with this.

 

Thanks,

atlantisatlantis

Hi Pam,

 

I dont know if Apex code have a way to generate a file and send it outside.

I wish you have good news and share with us.

 

 

Regards,

Atlantis

sri14sri14

can you please tell me with example code: How can we put the attachement( which is not at our local pc, it should be in SF/link) to FTP.

 

Ravi GandhiRavi Gandhi

I am looking for similar task "Take Attachment from SFDC Attachment object and drop to SFTP server." 

My thought was to call java script which can do Secure FTP connection first and then drop file using java script.  Any one have achieved something like this or have any ideas/code to share ?

Would greatly appreciate.

Thanks

Ravi

Meenu sharma 10Meenu sharma 10
Hi
Is it possible to use external storage to store Attachments?
As a company we have large files that sales need to upload and associate documents to opportunities. We also want to save on the Salesforce storage costs.
To the sales user it would appear that the attachment is being uploaded into SFDC but behind the scenes it would saved on something like netwotk storage. We need to store files on NAS (network storage) . In SFDC , we store Links to Edit/View/Del the attachment  that would be redirected to do the operation on the file in external storage.
 
External Drive: We need to store files at following location from SFDC- 
\\ukcrmnas902\test
 
SalmanSalman
Hi atlantis,

Can you please check this application for Attachments,

MassMailer DOCS let’s you easily mass email email attachments to your leads or contacts while securely storing your files with Rackspace Cloud Files.


You can try this app by installing from appexchange  -Massmailer Docs

You can learn more details about the product on this website - Link