The File Class Needs Documentation

I’ve been looking through a plugin that XAXA had released that allows you to temporarily store images from local files in Studio. Upon analysing its source code, I’ve found some examples of code that include method/class names I could neither find within the rest of the project, nor on the DevHub:

file:IsA("File")
file:GetBinaryContents()
file:GetTemporaryId()

As it turns out, I’ve discovered an entire class that isn’t documented at all: File. It yet managed to be implemented in a number of other plugins (i.e. Rōblox’s terrain height-map importer). It’s becoming apparent that the aforementioned plugins might mark the start a trend: where developers begin to utilise Studio’s cache more extensively. So, I believe something needs to be done to make it easier for other developers to access File. One way to significantly help is to make documentation public; File is only locked under PluginSecurity, whilst some CoreScript-exclusive members are listed publicly (i.e. RequestFriendship). Thank you for taking the time to read this.

The reference information can be accessed here.

14 Likes

It’s been 2 years and the File class documentation is still useless to me as a develop as I cannot use it’s functions due to missing documentations for GetBinaryContents() and GetTemporaryId() along with a few other missing documentations.

image

1 Like

It isn’t really hard to understand what the File methods do using the short description and just simply testing them out.

File:GetBinaryContents() - Return the binary contents of a file. If it’s plaintext, return the text, If it’s an image, for example, return the image binary.

File:GetTemporaryId() - Return the temporary rbxId that can be used in ImageLabel.Image & ImageButton.Image. Is in the format of rbxtemp://<numberOfImportedImage> (first is rbxtemp://1, second is rbxtemp://2, etc.)

This is false. If you attempt do this on an image, you get this:

image

…?

That is what the binary contents of the image are. If you edit the same image in Notepad you will get the exact same thing.

1 Like

Oh? Its suppose to that? Ok my bad. I expected getting binary contents of an image to contain a lot more than that

It does. A given image can be, let’s say, 20kb. That is 20,000 bytes. Each character that you see in the printed output is one byte.

You can run this in the command bar to see:

print(game:GetService("StudioService"):PromptImportFile({"png"}):GetBinaryContents())

or for the length:

print(table.getn(string.split(game:GetService("StudioService"):PromptImportFile({"png"}):GetBinaryContents(), "")))