LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Client
  • AsyncClient
  • Run Helpers
  • Run Trees
  • Evaluation
  • Schemas
  • Utilities
  • Wrappers
  • Anonymizer
  • Testing
  • Expect API
  • Middleware
  • Pytest Plugin
  • Deployment SDK
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewClientAsyncClientRun HelpersRun TreesEvaluationSchemasUtilitiesWrappersAnonymizerTestingExpect APIMiddlewarePytest PluginDeployment SDK
Language
Theme
PythonlangsmithresourcessandboxesboxesBoxesResourcegenerate_download_url
Method●Since v0.14

generate_download_url

Copy
generate_download_url(
  self,
  name: str,
  *,
  path: str,
  
View source on GitHub
content_disposition
:
str
|
Omit
=
omit
,
content_type
:
str
|
Omit
=
omit
,
csp_sandbox
:
bool
|
Omit
=
omit
,
csp_sandbox_flags
:
List
[
Literal
[
'allow-downloads'
,
'allow-forms'
,
'allow-modals'
,
'allow-orientation-lock'
,
'allow-pointer-lock'
,
'allow-popups'
,
'allow-presentation'
,
'allow-scripts'
,
'allow-top-navigation-by-user-activation'
,
'allow-same-origin'
]
]
|
Omit
=
omit
,
csp_source_bundles
:
List
[
Literal
[
'cdnjs'
,
'google-fonts'
,
'jsdelivr'
,
'unpkg'
,
'none'
,
'any'
]
]
|
Omit
=
omit
,
expires_in_seconds
:
int
|
Omit
=
omit
,
extra_headers
:
Headers
|
None
=
None
,
extra_query
:
Query
|
None
=
None
,
extra_body
:
Body
|
None
=
None
,
timeout
:
float
|
httpx
.
Timeout
|
None
|
NotGiven
=
not_given
)
->
DownloadURLResponse

Parameters

NameTypeDescription
csp_sandboxbool | Omit
Default:omit

CSPSandbox false serves the file with no CSP sandbox directive; omit to keep it.

csp_sandbox_flagsList[Literal['allow-downloads', 'allow-forms', 'allow-modals', 'allow-orientation-lock', 'allow-pointer-lock', 'allow-popups', 'allow-presentation', 'allow-scripts', 'allow-top-navigation-by-user-activation', 'allow-same-origin']] | Omit
Default:omit
csp_source_bundlesList[Literal['cdnjs', 'google-fonts', 'jsdelivr', 'unpkg', 'none', 'any']] | Omit
Default:omit
expires_in_secondsint | Omit
Default:omit
extra_headersHeaders | None
Default:None
extra_queryQuery | None
Default:None
extra_bodyBody | None
Default:None
timeoutfloat | httpx.Timeout | None | NotGiven
Default:not_given

Generate a tokenized link that downloads a single file from a sandbox with no further authentication. This mints a token rather than creating an addressable resource, so it returns 200 with no Location header. The token pins the sandbox, the file path, the response content type and disposition, and the sandbox flags, so a link cannot be repointed at another file or served under a weaker policy. The file is always served with a Content-Security-Policy: a sandbox directive, plus a default-src holding every fetch to the file's own download host and a set of pre-approved third-party origins. csp_sandbox_flags may loosen the sandbox with allow-downloads, allow-forms, allow-modals, allow-orientation-lock, allow-pointer-lock, allow-popups, allow-presentation, allow-same-origin, allow-scripts, or allow-top-navigation-by-user-activation. Every file is served from its own host, derived from the sandbox and the path, so allow-same-origin gives a page localStorage and IndexedDB that no other file can read, and re-minting a link for the same file keeps them. csp_sandbox set to false drops the sandbox directive altogether, and csp_sandbox_flags must then be omitted. csp_source_bundles selects the third-party origins: cdnjs, google-fonts, jsdelivr, and unpkg are all allowed when the field is omitted, 'none' holds the file to its own host, and 'any' sends no default-src at all. Links never expire unless expires_in_seconds is set. The link is served from the sandbox service domain, not the API host.

CSPSandboxFlags loosen the CSP sandbox the file is served under; omit for the most restrictive policy.

CSPSourceBundles allow the served file to fetch from named third-party origins; omit to send no fetch directive.

ExpiresInSeconds is optional; a link with no expiry never expires.

Send extra headers

Add additional query parameters to the request

Add additional JSON properties to the request

Override the client-level default timeout for this request, in seconds