In 15, you can use the "store a reference" option when inserting the file into a container field.
Your script can check the file extension and use the correct insert method for the type of file, using insert file for text files, insert picture for image files and insert PDF for inserting PDF's into an interactive container field for example.
You could also define a calculation field with "container" as the result type that uses your text field's file path, but you'd need to study the full text inserted "by reference" via the different insertion script steps for the different file types and build that into a case function. Note that GetasText ( containerField ) will return the full contents of the text you need to reproduce if you want to check this in the data viewer.
For image files and PDFs, many developers use the path with a web viewer.