Rikulo Stream serve specified file - stream

How do I serve a file that I specify in Rikulo stream without doing a redirect. I was trying
new ResourceLoader('my_app').load(connect, 'alternate.html');
from the plugin package but I receive the error:
type 'String' is not a subtype of type 'Path' of 'rootDir'

Replace the string 'my_app' with an object path that somehow contains the string.

Related

is possible to read a URL compressed with gzip (tvs.gz) with CSVProvider in F#?

is possible to read a URL compressed with gzip (tvs.gz) with CSVProvider in F#? Im trying with this code:
type name = CsvProvider<"https://datasets.imdbws.com/name.basics.tsv.gz", "\t">
But, I'm getting this error:
The type provider 'ProviderImplementation.CsvProvider' reported an error: Cannot read sample CSV from 'https://datasets.imdbws.com/name.basics.tsv.gz': Couldn't parse row 1 according to schema: Expected 2 columns, got 1
So, is possible to use a type provider in F# to do easy analisys over compressed CSVs?
You'll need to decompress the file with something like GZipStream, before being able to read it with CsvProvider.

How to change new File method in Groovy?

How do I replace the new File method with a secure one? Is it possible to create a python script and connect it?
Part of the code where I have a problem:
def template Name = new File(file: "${template}").normalize.name.replace(".html", "").replace(".yaml", "")
But when I run my pipeline, I get the error
java.lang.SecurityException: Unable to find constructor: new java.io .File java.util.LinkedHashMap
This method is prohibited and is blacklisted. How do I replace it and with what?
If you're reading the contents of the file, you can replace that "new File" with "readFile".
See https://www.jenkins.io/doc/pipeline/steps/workflow-basic-steps/#readfile-read-file-from-workspace
readFile: Read file from workspace
Reads a file from a relative path (with root in current directory, usually > workspace) and returns its content as a plain string.
file : String
Relative (/-separated) path to file within a workspace to read.
encoding : String (optional)
The encoding to use when reading the file. If left blank, the platform default encoding will be used. Binary files can be read into a Base64-encoded string by specifying "Base64" as the encoding.

FSharp.Data: EmbeddedResource option is ignored

I am using the XML Type Provider with FSharp.Data. I have a line like this:
type internal SomethingFromXML = XmlProvider<"./Sample.xml", EmbeddedResource="MyLib, Sample.xml">
I set the Sample.xml to "Embedded Resource, Do Not Copy".
I packed the MyLib to a NuGet package and used it in another program. But when I now execute it, I get a DirectoryNotFoundException saying it can't find C:\Path\To\My\SolutionWithMyLib\MyLib\Sample.xml
So, it seems to ignore the EmbeddedResource directive. Is that not supported with the XML Provider, or am I missing anything?

File object from URL

I'd like to create a file object from an image located at a specific url. I'm downloading the file with Net Http:
img = Net::HTTP.get_response(URI.parse('https://prium-solutions.com/wp-content/uploads/2016/11/rails-1.png'))
file = File.read(img.body)
However, I get ArgumentError: string contains null byte when trying to read the file and store in into the file variable.
How can I do this without having to store it locally ?
Since File deals with reading from storage, it's really not applicable here. The read method is expecting you to hand it a location to read from, and you're passing in binary data.
If you have a situation where you need to interface with a library that expects an object that is streaming, you can wrap the string body in a StringIO object:
file = StringIO.new(img)
# you can now call file.read, file.seek, file.rewind, etc.

web2py, URL() error when dynamically serving static files

I am generating static files on the fly but cannot get the URL function to work:
NB: here filename is a key-value returned by the controller
{{=P(A('Download ', filename,_href=URL('static', filename)))}}
generates an error:
type 'exceptions.SyntaxError'> when calling URL, function or function name required
However if I replace the filename variable with a string (as follows) the link is generated OK
{{=P(A('Download ', filename,_href=URL('static', 'abcis_data_42Data_.NO2.__.zip')))}}
Any ideas?
OK solved. filename is of type unicode and using str(filename) solves the problem.
I think what you might have to do here is go down the MVC hierarchy, so your code might look like:
{{=P(A('Download',filename,_href=URL(r=request,c='static',f=filename)))}}

Resources