You are viewing limited content. For full access, please sign in.

Question

Question

Importing files downloaded via an HTTP Get activity

asked on May 21, 2016 Show version history

I have a web server that is hosting some files. Path examples:

https://myserver/files/file1.png

https://myserver/files/file2.docx

https://myserver/files/file3.xlsx

I would like Workflow to download these files and import them into the repository. I played around with it some, but couldn't get it to work very well.

I have an HTTP GET activity pointing to each of the file locations.

Then I create a blank document and use the Attach Electronic Document activity with these settings:

So far so good. This is where it goes sideways though. Instead of the proper file type (png, docx, etc.), Workflow attaches a .response file to the entry:

This is what the token view shows for the instance:

Obviously, double-clicking the file fails to open it with the corresponding application, since ".response" is not a valid extension.

I can see from the file size that it's the correct file, and I can actually open it if I pick the application manually on the "Open with" dialogue box that pops up. The extension is just incorrect, so double-clicking it form the Client doesn't open it automatically. Do I need to process it further using a script?

0 0

Answer

SELECTED ANSWER
replied on May 23, 2016

Workflow wraps the downloaded files in a .response extension to protect against accidentally running them by double-clicking them on the WF Server's disk. The true extension is available, but Attach Electronic Document does not use it.

The original use case for these activities was that the response would be used with Read JSON/XML, not imported into Laserfiche. We'll look into adding an option to Attach Electronic Document to preserve the extension.

1 0
replied on May 23, 2016

Thanks Miruna, that makes sense.

There are a lot of use cases for downloading files using the HTTP activity. Remote FTP servers, services like Dropbox, etc. any service that makes files available for download can become a data source for the repository, and it can eliminate the need for more complex (e.g. API-level) integrations with those services.

Thanks for looking into it!

 

0 0
replied on August 14, 2023 Show version history

Hi

Was the ability to maintain the original File Extension ever supported when Attaching an Electronic Document?

We are downloading attachments from a WebAPI and even though the file name returned does not include the .response extension when attaching the Electronic Document it is being wrapped with .response.

0 0
replied on August 17, 2023

@████████

 Is there any update for this option? We have to "fix" this extension otherwise end user will have to rename them manually.

1 0

Replies

replied on May 22, 2016 Show version history

After some more fiddling, I was able to get it working property using this SDK script:

DocumentInfo docInfo = this.BoundEntryInfo as DocumentInfo;
string fileExtension = GetTokenValue("File extension").ToString();
if (docInfo != null && docInfo.IsElectronicDocument)
{
    this.DesignTools.Watch("Extension", docInfo.Extension);
    docInfo.Extension = fileExtension;
    docInfo.Save();
}

I'm getting the file extension off the URL using pattern matching, then using that to manually change the document's extension.

That said, it's bizarre that I have to do this in the first place. I feel like files downloaded via HTTP GET should retain their extensions rather than getting it changed to .response. It should work just like a file download on a browser.

The script method shown above wouldn't work if the URL did not expose the file's extension (e.g. if it was coming from a download handler, similar to how Forms handles files attached to file upload fields).

0 0
replied on December 5, 2016 Show version history

Hi,

 

I've got exactly the same problem, and it looks like your script is what I need. I can't work out what entry to create the file extension token and pass it as the 'scripts default entry' for it to work and when I run the script I have the error:

 

05/12/2016 13:01:58SDK ScriptThe token 'File extension' was not found. [0511-WF1]

 

I've manually set the name as '.pdf' because in this instance they're always PDF's and that works (thanks!) but I'd like to make it generic like yours.

 

Can you give a bit more on where to put it in the workflow?

 

Edit: worked it out, thanks for the post above though, got me sorted out :)

 

Thanks

0 0
replied on December 5, 2016

Hey Simon,

In my case, I make two HTTP GET requests. The first one returns a JSON that contains the URL of the file to be downloaded, which contains the file name. I grab the extension from there using pattern matching - that's where my FileExtension token comes from.

My script is bound to the activity that creates a blank Laserfiche document - the one I attach the downloaded document to using Attach Electronic Document.

0 0
You are not allowed to follow up in this post.

Sign in to reply to this post.