Accessing File object

How can I use File: GetBinaryContents () to allow importing local files from the computer?

More importantly, how do I even access it? There’s only documentation on the API reference, no code samples or anything, and clicking the function throws a 404 (missing page).

This plugin:

allows you to access files from your computer, it uses this File object somehow I believe - but how?

1 Like

StudioService:PromptImportFile returns a File object, so if i create a plain text file with “Hello World” inside it and then use GetBinaryContents() i’ll end up getting “Hello World” back:

local Studio = game:GetService("StudioService")
local obj = Studio:PromptImportFile({"txt"})

print(obj:GetBinaryContents()) -->> Hello World

For uploading assets you can generate a temporary asset id and do something like this for example:

local Studio = game:GetService("StudioService")
local Coregui = game:GetService("CoreGui")

local ScreenGui = Instance.new("ScreenGui", Coregui)
local ImageLabel = Instance.new("ImageLabel")


local obj = Studio:PromptImportFile({"png"})
ImageLabel.Image = obj:GetTemporaryId()


ImageLabel.Position = UDim2.new(.5,0,.5,0)
ImageLabel.Size = UDim2.new(.5,0,.5,0)
ImageLabel.AnchorPoint = Vector2.new(.5,.5)
ImageLabel.Parent = ScreenGui
4 Likes