2

I want to read a text file present in a server from my Roku program. I reffered the following question. Read and write from temp file in Roku

The above link has solution to read file from tmp/. So, I tried something like this:

text=ReadAsciiFile("<server_file_path>/file.txt")

But it is not able to open the file. Is there any other way to read a text file present in server?

Community
  • 1
  • 1
MayurK
  • 1,925
  • 14
  • 27

2 Answers2

3

ReadAsciiFile() is only used to read files from pkg:/ and tmp:/ directories. You should use rourltransfer for this.

  • I followed this example: https://sdkdocs.roku.com/display/sdkdoc/Downloading+Server+Content But the creation of roSGNode object is failing. – MayurK Jul 11 '16 at 07:53
  • roSGNode creation issue is resolved. I was creating roSGNode before roSGScreen, which is not allowed. But I am not getting call to sub getContent(). – MayurK Jul 11 '16 at 08:23
  • Hi @Roman Parashchyn! Do you have any sample code for "rourltransfer "? – MayurK Jul 11 '16 at 12:25
0

The code given in SDK document is too complicated for just to read a text file from server.

The following code worked from me.

Sub readTextFromServer(serverURL as String) as String
        readInternet = createObject("roUrlTransfer")
        print "Getting URL from: ";serverURL
        readInternet.setUrl(serverURL)
        myText= readInternet.GetToString()
        print "Text from server: ";myText

        return myText
End Sub
MayurK
  • 1,925
  • 14
  • 27