# File Access on host from remote client

**URL:** <https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741>\
**Category:** Archived Topics\
**Created:** [July 20, 2008, 4:00pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741 "2008-07-20T16:00:02Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![adamabelew](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adamabelew](https://forum.inductiveautomation.com/u/adamabelew)\
**Post date:** [July 20, 2008, 4:00pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/1 "2008-07-20T16:00:02Z")

</div>

I am looking to have the ability to view pdf files that reside on the host client from any of the remote clients. Specifically I have a pdf viewer with a file explorer on the same window to select which pdf file to view.

I attempted to use:

file:\192.168.1.1\C:\Reports\report01.pdf

any ideas?

Thanks

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 20, 2008, 7:40pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/2 "2008-07-20T19:40:26Z")

</div>

Getting windows network file paths right can be tricky, maybe try:

```auto
\\192.168.1.1\C$\Reports\report01.pdf
```

or

```auto
file://192.168.1.1\C$\Reports\report01.pdf
```

or share the reports folder on the server to get rid of the C$ part

---

<div class="post-metadata">

**Author:** ![adamabelew](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adamabelew](https://forum.inductiveautomation.com/u/adamabelew)\
**Post date:** [July 21, 2008, 12:41pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/3 "2008-07-21T12:41:33Z")

</div>

Carl,

Thanks for the suggestions. It looks like: \192.168.1.1\Reports\report01.pdf works. I did have to share the directory.

Thanks again,

Adam

---

<div class="post-metadata">

**Author:** ![adamabelew](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adamabelew](https://forum.inductiveautomation.com/u/adamabelew)\
**Post date:** [July 22, 2008, 3:47pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/4 "2008-07-22T15:47:43Z")

</div>

OK Carl, Issue back open.

It looks like for this to function, in other words for me to be able to access the shared directory, I need to login to the pc. This is why it was working for me the other day.

Is there a way to “Force” the directory viewer to the local (on the host) specific directory?

Can I do something like: “file://LocalHost/C:/Reports/”  
OR does that not make sense?

thanks again,  
Adam

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 22, 2008, 4:18pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/5 "2008-07-22T16:18:05Z")

</div>

No, that doesn’t make sense. In order to use windows filesharing, you’ll have convince windows that you have permissions to the file. So either you configure the share on the host computer to let anyone read from it, or you log in first.

The other option is to use something other than windows filesharing. Conveniently, you already have a web server (FactoryPMI Gateway) installed. If you drop files under the C:\Program Files\Inductive Automation\FactoryPMI\tomcat\webapps\ROOT directory, they will be served up over http, and you can access them like this:

[your.ip.here:8080/yourfile.pdf](http://your.ip.here:8080/yourfile.pdf)

---

<div class="post-metadata">

**Author:** ![nathan](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@nathan](https://forum.inductiveautomation.com/u/nathan)\
**Post date:** [July 23, 2008, 12:02am UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/6 "2008-07-23T00:02:43Z")

</div>

You have a number of options:

1. Store it on the FactoryPMI Gateway (Web server) as Carl suggested.
2. Store it in a BLOB in the SQL Database.
3. Try mapping the network share as a lettered “drive”. You would use the  
fpmi.system.execute() function to run the command.

The DOS command is: “net use”, “net use /help” will give you the optional paramaters. It includes options for a username and password.

For example: "net use s: \192.168.1.1\Reports\ password /USER:myusername

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 23, 2008, 12:13am UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/7 "2008-07-23T00:13:16Z")

</div>

I spoke with Adam earlier today on the phone. He is going to store the PDFs as BLOBs in the database - much more user friendly to skip the hassle of dealing with windows filesharing.

---

<div class="post-metadata">

**Author:** ![adamabelew](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adamabelew](https://forum.inductiveautomation.com/u/adamabelew)\
**Post date:** [July 23, 2008, 3:04pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/8 "2008-07-23T15:04:32Z")

</div>

Yes, After speaking with Carl yesterday, we decided to save my report as a PDF into the db as BLOB.

We worked on the scripting to get the data from the db and put dynamically into a PDF viewer component. I, however, think my script to save the report into the db is not working. Below are my scripts.

This is the code to save the report in the db. I have a BLOB type column in the table called “printedreports”:

`report = event.source.parent.getComponent('Report Viewer')
fileName = "ReportName"
filedata = report.getBytesPDF()
fpmi.db.runPrepStmt("UPDATE printedreports SET pdfBytes = (?) WHERE filename = (?)", [filedata, fileName])`

This is the code to retrieve the BLOB data:

`	filename = "2008-07-23 0500"
	bytes = fpmi.db.runQuery("SELECT pdfBytes FROM printedreports WHERE filename='%s'"%filename)
	tempfile = fpmi.file.getTempFile("pdf")	# Create Temp PDF File place holder
	fpmi.file.writeFile(tempfile, bytes)	#Generate Temporary PDF File
	event.source.parent.getComponent("PDF Viewer").filename = 'tempfile'`

when I run either script, I do not get errors. When I run the retrieval script, I do not see the pdf file. Also, when I view the temp file, I do not see anything. It is only 1k rather than the 4k size that the actual pdf’s are.

Any ideas?

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 23, 2008, 3:19pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/9 "2008-07-23T15:19:35Z")

</div>

Try these modifications to your scripts:

`report = event.source.parent.getComponent('Report Viewer')
fileName = "ReportName"
fileData = report.getBytesPDF()
fpmi.db.runPrepStmt("UPDATE printedreports SET pdfBytes = ? WHERE filename = ?", [fileData, fileName])`

and

`filename = "2008-07-23 0500"
bytes = fpmi.db.runQuery("SELECT pdfBytes FROM printedreports WHERE filename='%s'"%filename)
if len(bytes)>0:
   tempfile = fpmi.file.getTempFile("pdf") # Create Temp PDF File place holder
   fpmi.file.writeFile(tempfile, bytes[0][0]) #Generate Temporary PDF File
   event.source.parent.getComponent("PDF Viewer").filename = tempfile
else:
   fpmi.gui.warningBox("No report for filename '%s'" % filename)`

Hope this helps,

---

<div class="post-metadata">

**Author:** ![adamabelew](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adamabelew](https://forum.inductiveautomation.com/u/adamabelew)\
**Post date:** [July 23, 2008, 3:42pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/10 "2008-07-23T15:42:34Z")

</div>

Carl,

Yes it worked. It looks like that did the trick. I guess between grabbing as a byte array as well as my extra parenthesis around the “?” did the trick.

Thanks again,

Adam

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 23, 2008, 3:47pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/11 "2008-07-23T15:47:06Z")

</div>

The main problem was writing the variable bytes to the temp file. [color=GRAY](yes - thats what I told you to do on the phone yesterday - my bad)[/color]

bytes is a PyDataSet - the return of a query. using bytes[0][0] gets the value from the first row, first column, which is the BLOB data.

---

<div class="post-metadata">

**Author:** ![adamabelew](https://avatars.discourse-cdn.com/v4/letter/a/97f17d/32.png) [@adamabelew](https://forum.inductiveautomation.com/u/adamabelew)\
**Post date:** [July 23, 2008, 4:34pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/12 "2008-07-23T16:34:07Z")

</div>

One minor problem I now have is that inthe code where we make sure data is there before creating the temp file:

```auto
if len(bytes)>0:
```

The return of this is always 1 as this is the length of the array.

Is there a way to get the actual number of bytes of the data? This way we can differentiate between a return with NULL (not saved to) and actual PDF data that has been saved.

Thanks for your patience with my lack of knowledge on this.

EDIT:

As a quick fix, I added into my loading of the dataset: WHERE pdfBytes is not NULL which works for me for now…

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [July 23, 2008, 5:00pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/13 "2008-07-23T17:00:32Z")

</div>

Yep, the WHERE clause is a good way of doing it. The len(bytes) check is to make sure the database returned at least 1 row.

---

<div class="post-metadata">

**Author:** ![chris\_d\_sanders](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/chris_d_sanders/32/3359_2.png) [@chris\_d\_sanders](https://forum.inductiveautomation.com/u/chris_d_sanders)\
**Post date:** [November 19, 2009, 8:14pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/14 "2009-11-19T20:14:29Z")

</div>

I would be VERY interested in using something like this. Anyway I can get a copy of the window or HOW TO??

I follow the code, but unsure about certain elements within it…

Like:

```auto
fileData = report.getBytesPDF()
```

---

<div class="post-metadata">

**Author:** ![Carl.Gould](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/carl.gould/32/7262_2.png) [@Carl.Gould](https://forum.inductiveautomation.com/u/Carl.Gould)\
**Post date:** [November 21, 2009, 10:51pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/15 "2009-11-21T22:51:33Z")

</div>

That line simply retrieves the currently displayed chart as the bytes of a PDF. You could write these bytes to a \*.pdf file, or email the bytes to someone as a \*.pdf, or store them in the database for later retrieval.

---

<div class="post-metadata">

**Author:** ![StriderPR](https://avatars.discourse-cdn.com/v4/letter/s/838e76/32.png) [@StriderPR](https://forum.inductiveautomation.com/u/StriderPR)\
**Post date:** [September 2, 2010, 1:44pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/16 "2010-09-02T13:44:42Z")

</div>

Hi,  
Iam trying to access pdf file stored at the Gateway Server (Ignition) from the clients. I dont want to stored then in a DB. What else can I do?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 2, 2010, 3:31pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/17 "2010-09-02T15:31:03Z")

</div>

You can create a shared folder on the gateway to access the PDFs from.

---

<div class="post-metadata">

**Author:** ![jcjeppesen](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jcjeppesen](https://forum.inductiveautomation.com/u/jcjeppesen)\
**Post date:** [March 7, 2013, 3:05pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/18 "2013-03-07T15:05:31Z")

</div>

Ok I placed the file here and can pull it up from any computer on the network…

[MYHOST.com:8088/main/dar.pdf](http://MYHOST.com:8088/main/dar.pdf)

But it will not show up in the PDF viewer in my project…

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [March 7, 2013, 6:18pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/19 "2013-03-07T18:18:40Z")

</div>

What error or you getting? Are you using the PDF viewer component under reporting or the ActiveX adobe reader?

---

<div class="post-metadata">

**Author:** ![jcjeppesen](https://avatars.discourse-cdn.com/v4/letter/j/ee7513/32.png) [@jcjeppesen](https://forum.inductiveautomation.com/u/jcjeppesen)\
**Post date:** [March 7, 2013, 6:49pm UTC](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741/20 "2013-03-07T18:49:25Z")

</div>

Hi.  
Im using ICEpdf-Viewer.  
It also works fine if I use this Add but only on the localhost not on the network for clients. Half my clients running Ubuntu so no Acitvx.  
C:\Program Files\Inductive Automation\Ignition\tomcat\webapps\main/dar.pdf

Error:  
Componet name"[http://IPADD:8088/main/dar.pdf](http://IPADD:8088/main/dar.pdf)" is invalid, it is either non-unique,reserved, or has an illegal charactr.

[Next page](https://forum.inductiveautomation.com/t/file-access-on-host-from-remote-client/741.md?page=2)
