StaticResource

Represents a static resource file, often a code library in a ZIP file. Static resources allow you to upload content that you can reference in a Visualforce page, including archives (such as .zip and .jar files), images, style sheets, JavaScript, and other files. Static resources can be used only within your Salesforce org, so you can’t host content here for other apps or websites.

Parent Type 

This type extends MetadataWithContent and inherits its fields.

File Suffix and Directory Location 

The file suffix is .resource for the template file. The accompanying metadata file is named resource-meta.xml.

Static resource components are stored in the staticresources folder in the corresponding package directory.

Version 

Static resources are available in API version 12.0 and later.

Fields 

cacheControl 

  • Type: StaticResourceCacheControl (enumeration of type string)

  • Required: Yes

  • Description: Required. Indicates whether the static resource is marked with a public caching tag so that a third-party delivery client can cache the content. This field is available in API version 14.0. The valid values are:

    • Private
    • Public

content 

  • Type: base64Binary
  • Required: No
  • Description: The static resource content. Base 64-encoded binary data. Before making an API call, client applications must encode the binary attachment data as base64. Upon receiving a response, client applications must decode the base64 data to binary. This conversion is handled for you by a SOAP client. This field is inherited from the MetadataWithContent component.

contentType 

  • Type: string
  • Required: Yes
  • Description: Required. The content type of the file, for example text/plain.

description 

  • Type: string
  • Required: No
  • Description: The description of the static resource.

fullName 

  • Type: string

  • Required: No

  • Description: The static resource name. The name can only contain characters, letters, and the underscore (_) character. The name must start with a letter, and can’t end with an underscore or contain two consecutive underscore characters.

    Inherited from the Metadata component, this field isn’t defined in the WSDL for this component. It must be specified when creating, updating, or deleting. See create() to see an example of this field specified for a call.

Declarative Metadata Sample Definition 

1<?xml version="1.0" encoding="UTF-8"?>
2<StaticResource xmlns="http://soap.sforce.com/2006/04/metadata">
3    <contentType>text/plain</contentType>
4    <description>Test Resource</description>
5</StaticResource>

Wildcard Support in the Manifest File 

This metadata type supports the wildcard character * (asterisk) in the package.xml manifest file. For information about using the manifest file, see Deploying and Retrieving Metadata with the Zip File.