As stated in the documentation for both StudioService:PromptImportFile()
and StudioService:PromptImportFiles()
, these methods shall return nil if no file was selected, or if the file size exceeds 100 MB. They return as expected when no file is selected, but when a file that exceeds 100 MB is selected, it returns a file object, when the expected behavior (according to documentation) is that they would return nil. I would prefer an error be thrown upon attempted import rather than returning nil for both instances (no file selected or file too large).
Instead, an error is thrown upon calling File:GetBinaryContents()
:
GetBinaryContents: Cannot open file largefile.txt. Size exceeded 100000000 bytes. Size: 335118336.
Simple repro, install the script below as a plugin to your local plugin folder and import a file larger than 100 MB
local StudioService = game:GetService("StudioService")
local file = StudioService:PromptImportFile()
if (file) then
local fileSize = file.Size
if (fileSize > 100000000) then
warn("The file you imported is larger than 100 MB. PromptImportFile should have returned nil (or preferably thrown an error), but it didn't... so enjoy this error!")
file:GetBinaryContents()
end
end
Workaround
Call File:GetBinaryContents()
after the file is imported to throw an error because I can’t use the File object on file sizes larger than 100 MB
Issue Area: Studio
Issue Type: Other
Impact: Moderate
Frequency: Constantly
EDIT: It should also be noted that there is no documentation for File:GetBinaryContents()