Local Scheme Handler: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
(Created page with "__NOTOC__ In many cases it is necessary to access files stored on the local disk from browsers. {{New feature/item|3.0151|1.5.1|7439| ==Scheme format== <syntaxhighlight lang="lua">http://mta/resou...")
 
(Remove obsolete Requirements section)
 
(2 intermediate revisions by 2 users not shown)
Line 9: Line 9:


You can use this scheme format for [[loadBrowserURL]] as well as in HTML files e.g. <img> tags.
You can use this scheme format for [[loadBrowserURL]] as well as in HTML files e.g. <img> tags.
{{Requirements|1.5.0-9.07439|n/a|}}


==Examples==
==Examples==
Line 19: Line 16:


===Example 2===
===Example 2===
<syntaxhighlight lang="lua">http://mta/local/myImage.png</syntaxhighlight>
<syntaxhighlight lang="lua">http://mta/local/assets/myImage.png</syntaxhighlight>
Refers to the file ''myImage.png'' in the current resource
Refers to the file ''assets/myImage.png'' in the current resource
}}
}}


{{Deprecated_feature|3.0151|1.5.1|7439|
{{Deprecated_feature|3.0151|1.5.0-7439|
Test
Before build 1.5.0-7439 local files were accessed using the mtalocal:// scheme. This scheme has been deprecated now, but throws a warning and should not be used any longer for this reason.
Nevertheless, it still works for backward compatibility, but should be replaced as soon as possible. '''Don't forget to set min_mta_version though (when using the new scheme).'''
}}
}}

Latest revision as of 17:13, 7 November 2024

In many cases it is necessary to access files stored on the local disk from browsers.

Scheme format

http://mta/resourceName/file.extension
  • resourceName: The resource name, local is a special name for the current resource
  • file.extension: The file path within resourceName

You can use this scheme format for loadBrowserURL as well as in HTML files e.g. <img> tags.

Examples

Example 1

http://mta/myResource/assets/myImage.png

Refers to the file assets/myImage.png in a resource named myResource

Example 2

http://mta/local/assets/myImage.png

Refers to the file assets/myImage.png in the current resource