Child pages
  • UAPI Functions - Fileman::get_file_content

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

Excerpt
This function retrieves a file's content.

Multiexcerpt include
SpaceWithExcerptcom.atlassian.confluence.content.render.xhtml.model.resource.identifiers.SpaceResourceIdentifier@12665
MultiExcerptNameAPIDisabledFileStorageRole
PageWithExcerptLIB:_ServerRoleDisabledAPI

Panel
bgColor#F2F2F2
borderStylenone

Examples


Panel
bgColor#FFFFFF
borderStylenone


Expand
titlecPanel or Webmail Session URL


Code Block
https://hostname.example.com:2083/cpsess##########/execute/Fileman/get_file_content?dir=home%2Fusername%2Fpublic_html&file=example.html&charset=utf-8&from_charset=_DETECT_&to_charset=_LOCALE_

 

Include Page
LIB:_CallUAPIFromBrowserLink
LIB:_CallUAPIFromBrowserLink


Expand
titleLiveAPI PHP Class


Code Block
languagephp
linenumberstrue
$cpanel = new CPANEL(); // Connect to cPanel - only do this once.
 
// Retrieve content from file.
$get_file_content = $cpanel->uapi(
    'Fileman', 'get_file_content',
		array(
		'dir'			=> '/home/user/public_html',
		'file'			=> 'example.html',
		'from_charset'	=> '_DETECT_',
		'to_charset'	=> '_LOCALE_',
	)
);

Include Page
LIB:_LiveAPIPHPLink
LIB:_LiveAPIPHPLink

 


Expand
titleLiveAPI Perl Module


Code Block
languageperl
linenumberstrue
my $cpliveapi = Cpanel::LiveAPI->new(); # Connect to cPanel - only do this once.
 
# Retrieve Content from file.
my $get_file_content = $cpliveapi->uapi(
 'Fileman', 'get_file_content',
		{
		'dir'			=> '/home/user/public_html',
		'file'			= 'example.html',
		'from_charset'	=> '_DETECT_',
		'to_charset'	=> '_LOCALE_',
		}
 );

Include Page
LIB:_LiveAPIPerlLink
LIB:_LiveAPIPerlLink

 


Expand
titlecPanel Template Toolkit


Code Block
languagexml
linenumberstrue
<!-- Get a hash of all the data, then display the content value. -->
[% data = execute( 'Fileman', 'upload_files' {dir => '/home/user/public_html, 'file' => 'example.html', 'from_charset' => '_DETECT_', 'to_charset' => '_LOCALE_'} ); %]
[% FOREACH q = data.content %]
     <p>
         [% q %]
     </p>
[% END %]
 
<!-- Get only a hash of the data. -->
[% execute('Fileman', 'upload_files' {dir => '/home/user/public_html, 'file' => 'example.html', 'from_charset' => '_DETECT_', 'to_charset' => '_LOCALE_',}  ).data.content %]

Include Page
LIB:_TTLink
LIB:_TTLink

 


Expand
titleCommand Line


Code Block
languagebash
uapi --user=username Fileman get_file_content dir=%2Fhome%2Fusername%2Fpublic_html file=example.html charset=utf-8 from_charset=_DETECT_ to_charset=_LOCALE_

Include Page
LIB:_UAPICLINote
LIB:_UAPICLINote


Expand
titleOutput (JSON)


Code Block
languagetext
linenumberstrue
{  
   "messages":null,
   "errors":null,
   "status":1,
   "metadata":{  

  },
  "data": {
	"from_charset": "utf-8",    
	"filename": "example.html",
    "to_charset": "utf-8",
    "content": ""hi"",
    "path": "/home/username/public_html/example.html",
    "dir": "/home/username/public_html"
  }
}


Include Page
LIB:_cPanelAPIShellNote
LIB:_cPanelAPIShellNote


Parameters

ParametersTypeDescriptionPossible valuesExample
dirstring

Required

The file path to the directory that contains the selected file.

The absolute path to the directory./home/user/public.html
filestring

Required

The files to retrieve.

A valid filename. example.html
from_charsetstring

The system's predefined encoding.

  • An encoding language.
  • _DETECT_auto-detect the selected file’s encoding type.

_DETECT_

 
to_charsetstring

The character set in which to encode the file.

  • An encoding language.
  • _LOCALE_look up the current locale's encoding language.

_LOCALE_

 

Returns

ReturnTypeDescriptionPossible valuesExample
dirstring

The file path to the directory that contains the selected file.

A valid absolute path./home/user/public_html
filenamestringThe file's name.A valid filename.example.html
pathstringThe path to the file.A valid absolute path./home/user/public_html/example.html
contentstringThe file's contents, encoded in the UTF-8 character set.A string value."hi"
from_charstring

The file's character set.

A cPanel-supported character set encoding.

 

UTF-8
to_charstring

The file's new character set.

A cPanel-supported character set encoding.

 

UTF-8