Local Asset Manager - A local file importing tool
Theres Some Plugin about Local Asset, But How They Works. I tried to read their source code,But i dont really understand. Or can someone provide a example code uploading .png,.jpg to rbxtemp? Thanks
Local Asset Manager - A local file importing tool
Theres Some Plugin about Local Asset, But How They Works. I tried to read their source code,But i dont really understand. Or can someone provide a example code uploading .png,.jpg to rbxtemp? Thanks
This most likely uses StudioService.PromptImportFile
which can be used like so:
local StudioService = game:GetService("StudioService")
-- Imports the File, with a .png and .jpg filter. This function will yield until the user selects a file, or cancels the prompt
local file = StudioService:PromptImportFile({"png", "jpg"})
-- file can be nil if the prompt was cancelled or if the file was larger than 100MB, so have a check for when that occurs
if file then
-- outputs the imported file's temporary id
print(file:GetTemporaryId())
end
Keep in mind that PromptImportFile
is PluginSecurity
, so this can only be used from a Plugin or the Command Bar so running this from a normal script will cause an error.
but its possible to import from buffer. like fetch image and get image buffer.
Files also have a function called GetBinaryContents
, which returns the raw binary of a file.
If you want to use buffers then you can use buffer.fromstring
with the binary contents.
local StudioService = game:GetService("StudioService")
-- Imports the File, with a .png and .jpg filter. This function will yield until the user selects a file, or cancels the prompt
local file = StudioService:PromptImportFile({"png", "jpg"})
-- file can be nil if the prompt was cancelled or if the file was larger than 100MB, so have a check for when that occurs
if file then
-- Gets the raw binary string of the file
local binaryContents = file:GetBinaryContents()
-- creates a buffer from the string above
local imageBuffer = buffer.fromstring(binaryContents)
-- code to mess with the buffer as you wish, using the buffer library
end
I assume this is what you mean by that.
Sorry. I mean upload image to rbxtemp with buffer. is this possible.
Or its possible to create “File” Instance
I’m sorry to disappoint, but Roblox does not have a way for us to do something like that.
File instances can’t be created with Instance.new() either, they’re only returned with the PromptImportFile(s) functions.