CINXE.COM
Netlify Blobs | Netlify Docs
<!DOCTYPE html> <html lang="en-US"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1"> <title>Netlify Blobs | Netlify Docs</title> <meta name="generator" content="VuePress 1.9.9"> <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,500,700,400italic|Roboto+Mono:400"> <link rel="icon" href="/netlify-icon.svg" type="image/svg+xml"> <link rel="apple-touch-icon" href="/apple-touch-icon.png"> <link rel="icon" href="/favicon-32x32.png" type="image/png" sizes="32x32"> <link rel="icon" href="/favicon-16x16.png" type="image/png" sizes="16x16"> <script>(function (w) { if (!w) return; const darkQuery = w.matchMedia('(prefers-color-scheme: dark)'); const root = document.documentElement; function setTheme(newTheme) { if (newTheme === 'dark' || (newTheme === 'system' && darkQuery.matches)) { root.classList.add('dark-mode'); } else { root.classList.remove('dark-mode'); } w.__theme = newTheme; } w.__setPreferredTheme = function (newTheme) { setTheme(newTheme); try { localStorage.setItem('nf-docs-theme', w.__theme); } catch (err) {} }; // If using system theme, change colors in real time // in response to user settings darkQuery.addEventListener('change', function (event) { if (w.__theme === 'system') { if (event.matches) { root.classList.add('dark-mode'); } else { root.classList.remove('dark-mode'); } } }); let preferredTheme; // Try to get saved theme try { preferredTheme = localStorage.getItem('nf-docs-theme') || 'system'; } catch (err) {} // Initialize preferredTheme setTheme(preferredTheme); })(window);</script> <script src="/rum.js" data-application-id="ededf59a-7705-4933-b2a0-5efa8b35b293" data-client-token="pub1b84fc7c7429f37e025e8160c02da8bb" data-service="docs" data-env="production" defer="true"></script> <meta name="description" content="Store and retrieve unstructured data. Use blob storage as a simple key/value store or basic database."> <meta property="og:title" content="Netlify Blobs"> <meta property="og:url" content="https://docs.netlify.com/blobs/overview/"> <meta property="og:description" content="Store and retrieve unstructured data. Use blob storage as a simple key/value store or basic database."> <meta property="og:image" content="https://docs.netlify.com/og-image.png"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta prefix="og: http://ogp.me/ns#" property="og:type" content="article"> <meta prefix="og: http://ogp.me/ns#" property="og:article:author" content="Netlify"> <meta name="google-site-verification" content="G4JqDTXMHpDyWoqIRwgw8PBqg-AncXqtdkHehcOR7kc"> <meta name="slack-app-id" content="A05P27DR8C8"> <link href="https://docs.netlify.com/blobs/overview/" rel="canonical" /> <link rel="preload" href="/assets/css/0.styles.bebdbd1c.css" as="style"><link rel="preload" href="/assets/js/app.cc2f9ad6.js" as="script"><link rel="preload" href="/assets/js/10.a8fb7bb3.js" as="script"><link rel="preload" href="/assets/js/2.01499542.js" as="script"><link rel="preload" href="/assets/js/44.d25d9ab0.js" as="script"><link rel="preload" href="/assets/js/16.dc8f34ea.js" as="script"><link rel="preload" href="/assets/js/15.6d589b72.js" as="script"><link rel="preload" href="/assets/js/21.29480efd.js" as="script"><link rel="preload" href="/assets/js/11.470e17cb.js" as="script"><link rel="preload" href="/assets/js/9.ad446dfa.js" as="script"><link rel="preload" href="/assets/js/3.9ee141f4.js" as="script"> <link rel="stylesheet" href="/assets/css/0.styles.bebdbd1c.css"> </head> <body> <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-NMKKF2M" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript> <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar-header"><div class="navbar"><div class="navbar__logo-link"><a href="/" class="router-link-active"><span class="visuallyhidden">Netlify Docs</span> <svg width="146" height="40" viewBox="0 0 146 40" fill="none" xmlns="http://www.w3.org/2000/svg" class="netlify-lockup" data-v-4ee6c329><path d="M22.794 39.79V29.687l.21-.21h2.526l.21.21V39.79l-.21.209h-2.527l-.209-.21ZM22.794 10.314V.21l.21-.209h2.526l.21.21v10.104l-.21.21h-2.527l-.209-.21ZM14.1 32.687h-.347l-1.738-1.738v-.347l3.256-3.26 1.84.004.245.242v1.84L14.1 32.686ZM12.015 9.49v-.35l1.738-1.735h.347l3.256 3.256v1.836l-.246.248h-1.839L12.015 9.49ZM.582 18.524h14.316l.21.21v2.53l-.21.209H.582l-.21-.21v-2.53l.21-.209Z" fill="var(--lockup-lines-fill)" data-v-4ee6c329></path> <path d="M29.005 25.265h-2.526l-.21-.21v-5.912c0-1.054-.412-1.869-1.682-1.895-.654-.016-1.4 0-2.199.033l-.12.12v7.651l-.21.21h-2.526l-.21-.21V14.948l.21-.21h5.684a3.998 3.998 0 0 1 3.998 3.999v6.315l-.21.21v.003ZM41.24 20.841l-.21.21H34.5l-.21.209c0 .422.423 1.685 2.108 1.685.631 0 1.263-.21 1.476-.631l.21-.21h2.525l.21.21c-.21 1.263-1.263 3.16-4.424 3.16-3.58 0-5.265-2.526-5.265-5.477 0-2.952 1.685-5.478 5.055-5.478 3.37 0 5.056 2.526 5.056 5.478v.844Zm-3.161-2.107c0-.21-.21-1.686-1.895-1.686s-1.895 1.476-1.895 1.686l.21.21h3.37l.21-.21ZM47.136 22.104c0 .422.21.632.632.632h1.895l.209.209v2.107l-.21.21h-1.894c-1.895 0-3.58-.845-3.58-3.161v-4.634l-.21-.21h-1.475l-.21-.209v-2.107l.21-.21h1.476l.21-.209v-1.894l.209-.21h2.526l.21.21v1.894l.209.21h2.316l.21.21v2.106l-.21.21h-2.316l-.21.21V22.1l.003.003ZM54.93 25.265h-2.525l-.21-.21V10.73l.21-.21h2.526l.21.21v14.322l-.21.21v.003ZM60.618 13.046h-2.526l-.21-.209V10.73l.21-.21h2.526l.21.21v2.107l-.21.21Zm0 12.22h-2.526l-.21-.21V14.944l.21-.21h2.526l.21.21v10.112l-.21.21ZM70.52 10.73v2.107l-.21.21h-1.894c-.422 0-.632.209-.632.631v.844l.21.21H70.1l.21.21v2.106l-.21.21h-2.107l-.21.21v7.581l-.21.21H65.05l-.21-.21v-7.582l-.21-.21h-1.475l-.21-.209v-2.107l.21-.21h1.476l.21-.209v-.844c0-2.317 1.684-3.161 3.58-3.161h1.894l.21.21-.004.003ZM78.311 25.474c-.844 2.108-1.685 3.37-4.633 3.37h-1.054l-.21-.209v-2.107l.21-.21h1.054c1.053 0 1.263-.209 1.475-.84v-.21l-3.37-8.216v-2.108l.21-.21h1.894l.21.21 2.526 7.163h.21l2.525-7.163.21-.21h1.894l.21.21v2.108l-3.37 8.426.01-.004Z" fill="var(--lockup-wordmark-fill)" data-v-4ee6c329></path> <path d="M94.699 25.205V10.707l-.213-.214H92.78l-.213.214v5.117h-.213c-.661-.853-1.706-1.28-2.772-1.28-2.985 0-4.69 2.346-4.69 5.544 0 3.198 1.705 5.543 4.69 5.543 1.13 0 2.132-.469 2.772-1.28h.213l.213.854.213.213h1.493l.213-.213Zm-2.132-5.117c0 2.558-1.066 3.624-2.772 3.624-1.705 0-2.771-1.258-2.771-3.624 0-2.367 1.066-3.625 2.771-3.625 1.706 0 2.772 1.066 2.772 3.625ZM96.614 20.088c0 3.411 1.918 5.543 5.117 5.543 3.198 0 5.117-2.132 5.117-5.543 0-3.412-1.919-5.544-5.117-5.544s-5.117 2.133-5.117 5.544Zm2.132 0c0-2.346 1.066-3.625 2.985-3.625 1.918 0 2.985 1.28 2.985 3.625 0 2.345-1.067 3.624-2.985 3.624-1.92 0-2.985-1.279-2.985-3.624ZM110.26 20.088c0-2.346 1.066-3.625 2.985-3.625 1.705 0 2.345.853 2.558 1.706l.213.213h1.706l.213-.213c-.213-1.919-1.706-3.625-4.69-3.625-3.199 0-5.117 2.133-5.117 5.544 0 3.411 1.918 5.543 5.117 5.543 2.984 0 4.477-1.706 4.69-3.624l-.213-.213h-1.706l-.213.213c-.213.852-.853 1.705-2.558 1.705-1.919 0-2.985-1.279-2.985-3.624ZM127.733 22.433c0-1.919-1.066-2.772-3.199-3.198-2.132-.426-2.984-.64-2.984-1.706 0-.852.852-1.066 1.918-1.066 1.493 0 1.919.64 1.919 1.28l.214.213h1.705l.213-.213c0-2.132-1.705-3.198-4.051-3.198-2.984 0-4.05 1.492-4.05 2.984 0 1.92 1.279 2.772 3.411 3.198 2.132.427 2.772.64 2.772 1.706 0 .853-.64 1.28-2.133 1.28-1.492 0-2.132-.64-2.132-1.706l-.213-.213h-1.705l-.214.213c0 2.345 1.493 3.624 4.264 3.624 2.985 0 4.265-1.492 4.265-3.198Z" fill="var(--lockup-secondary-text-fill)" data-v-4ee6c329></path> <path d="M131.138 18.524h14.316l.209.21v2.53l-.209.209h-14.316l-.21-.21v-2.53l.21-.209Z" fill="var(--lockup-lines-fill)" data-v-4ee6c329></path></svg></a></div> <div class="navbar__actions-wrapper"><form id="search-form" role="search" class="algolia-search-wrapper search-form"><label class="search-form__label"><svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 32 32" class="search-form__label-icon-search"><path d="M20.571 15.143c0-4.411-3.589-8-8-8s-8 3.589-8 8 3.589 8 8 8 8-3.589 8-8zM29.714 30c0 1.25-1.036 2.286-2.286 2.286-0.607 0-1.196-0.25-1.607-0.679l-6.125-6.107c-2.089 1.446-4.589 2.214-7.125 2.214-6.946 0-12.571-5.625-12.571-12.571s5.625-12.571 12.571-12.571 12.571 5.625 12.571 12.571c0 2.536-0.768 5.036-2.214 7.125l6.125 6.125c0.411 0.411 0.661 1 0.661 1.607z" fill="rgba(175, 180, 182, 0.87)"></path></svg> <input id="algolia-search-input" placeholder="Search our docs by topic..." class="search-form__input"></label> <button tabindex="-1" type="reset" class="search-form__label-icon-close"><span class="visuallyhidden">Close search</span> <svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 18 18"><g fill="#A3A9AC" transform="scale(-1 1) rotate(45 .571 -12.959)"><rect width="2.333" height="18.667" x="8.164" y=".003"></rect> <polygon points="8.164 .003 10.497 .003 10.497 18.67 8.164 18.67" transform="rotate(-90 9.33 9.336)"></polygon></g></svg></button> <div class="search-form__content-overlay"></div></form> <div class="navbar__right-actions"><a href="/ask-netlify/" aria-label="ask netlify" class="navbar__ask-netlify-link"><span class="navbar__ask-netlify-icon"><svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 44 44" class="wrapper__icon-ask-netlify"><path fill="currentColor" d="M18.77 23.56a1.8 1.8 0 1 1-3.6 0 1.8 1.8 0 0 1 3.6 0Zm8.26 1.8a1.8 1.8 0 1 0 0-3.6 1.8 1.8 0 0 0 0 3.6Zm-3.86-1.54.03.07v.38l-.03.07-.87 1.77-.12.09h-.32l-.13-.1-.9-1.76-.03-.07v-.38l.03-.07 1-.66h.31l1.03.66Z"></path> <path fill="currentColor" fill-rule="evenodd" d="M22.32 13C28.77 13 34 17.22 34 23.67a6.97 6.97 0 0 1-6.97 6.97H10v-6.97C10 17.22 15.23 13 21.68 13h.64ZM11.55 23.16a5.24 5.24 0 0 1 10.07-2.05h.76l.01-.03a5.24 5.24 0 0 1 10.06 2.08c0 2.65-2.13 5.17-4.53 5.23H16.5a5.24 5.24 0 0 1-4.95-5.23Z" clip-rule="evenodd"></path> <path fill="currentColor" d="m24.47 8.12.07-.16 1.16-.4.15.08.63 1.95-.4.82-.16.06-.82-.4-.63-1.95Zm9.88 3.27.16.06.48 1.13-.07.16-1.9.76-.85-.34-.07-.16.35-.85 1.9-.76ZM30.04 8l.16-.06 1.1.54.05.16-1.14 2.43-.87.3-.15-.08-.3-.86L30.04 8Z" class="ask-netlify-flair"></path></svg></span> <span class="navbar__ask-netlify-label">Ask Netlify</span></a> <div class="user-menu"><!----> <button href="#menu" aria-label="menu" class="menu-trigger is-not-visible-mamabear"><svg viewBox="0 0 31 25" xmlns="http://www.w3.org/2000/svg" class="wrapper__icon-menu"><rect x="0.581177" y="0.71875" width="30" height="4" fill="currentcolor"></rect> <rect x="0.581177" y="10.7188" width="30" height="4" fill="currentcolor"></rect> <rect x="0.581177" y="20.7188" width="30" height="4" fill="currentcolor"></rect></svg></button> <nav aria-label="Netlify navigation" class="navbar__nav is-visible-mamabear navbar__authlinks" data-v-1733a580><div class="navbar__nav-list" data-v-1733a580><a href="https://app.netlify.com/login" rel="noopener noreferrer" class="navbar__nav-link" data-v-1733a580> Log in </a> <a href="https://app.netlify.com/signup" target="self" rel="noopener noreferrer" class="navbar__nav-link signup-button" data-v-1733a580> Sign up </a></div></nav></div></div></div></div></header> <main class="wrapper wrapper--main"><div class="wrapper__sidebar wrapper__navigation"><a class="button button--icon button--close is-not-visible-mamabear"><svg aria-hidden="true" width="24" height="24" viewBox="0 0 16 16" class="icon"><path d="M8,15 C4.13400675,15 1,11.8659932 1,8 C1,4.13400675 4.13400675,1 8,1 C11.8659932,1 15,4.13400675 15,8 C15,11.8659932 11.8659932,15 8,15 Z M10.44352,10.7233105 L10.4528296,10.7326201 L10.7326201,10.4528296 C11.0310632,10.1543865 11.0314986,9.66985171 10.7335912,9.37194437 L9.36507937,8.0034325 L10.7360526,6.63245928 C11.0344957,6.33401613 11.0349311,5.84948135 10.7370237,5.55157401 L10.448426,5.26297627 C10.1505186,4.96506892 9.66598387,4.96550426 9.36754072,5.26394741 L8.00589385,6.62559428 L6.63738198,5.25708241 C6.33947464,4.95917507 5.85493986,4.95961041 5.55649671,5.25805356 L5.26737991,5.54717036 C4.96893676,5.84561351 4.96850142,6.33014829 5.26640876,6.62805563 L6.62561103,7.9872579 L5.25463781,9.35823112 C4.95619466,9.65667427 4.95575932,10.141209 5.25366666,10.4391164 L5.5422644,10.7277141 C5.84017175,11.0256215 6.32470652,11.0251861 6.62314967,10.726743 L7.99412289,9.35576976 L9.36263476,10.7242816 C9.66054211,11.022189 10.1450769,11.0217536 10.44352,10.7233105 Z"></path></svg></a> <div aria-label="Docs" class="sidebar wrapper__sidebar-interior"><nav aria-label="Docs"><div><div class="sidebar__section"><span class="sidebar__section-label">Welcome</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/" aria-current="page" class="sidebar__link">Home</a></div></li><li class="sidebar__link-item"><div><a href="/get-started/" class="sidebar__link">Get started</a></div></li><li class="sidebar__link-item"><div><a href="/welcome/add-new-site/" class="sidebar__link">Add new site</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Get help </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Platform</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/platform/what-is-netlify/" class="sidebar__link">What is Netlify?</a></div></li><li class="sidebar__link-item"><div><a href="/platform/who-is-netlify-for/" class="sidebar__link">Who is Netlify for?</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Checklists </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> How we release </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Platform primitives</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/platform/primitives/" class="sidebar__link">Overview</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Functions </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Edge Functions </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Image CDN </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/blobs/overview/" aria-current="page" class="active sidebar__link">Blobs</a></div></li><li class="sidebar__link-item"><div><a href="/platform/caching/" class="sidebar__link">Caching</a></div></li><li class="sidebar__link-item"><div><a href="/platform/dev-server/" class="sidebar__link">Dev Server</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Platform extensions </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Frameworks</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/frameworks/" class="sidebar__link">Overview</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Framework support </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/frameworks/environment-variables/" class="sidebar__link">Use environment variables with frameworks</a></div></li><li class="sidebar__link-item"><div><a href="/frameworks-api/" class="sidebar__link">Frameworks API</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Developer tools</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> CLI </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> API </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/terraform-provider/" class="sidebar__link">Terraform Provider</a></div></li><li class="sidebar__link-item"><div><a href="https://developers.netlify.app/sdk/get-started/introduction/" target="_blank" rel="noopener noreferrer" class="sidebar__link">Netlify SDK</a></div></li><li class="sidebar__link-item"><div><a href="/welcome/command-palette/" class="sidebar__link">Command Palette</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Integrate & extend</span> <ul class="sidebar__links"><li class="sidebar__link-item"><div><a href="/integrations/overview/" class="sidebar__link">Overview</a></div></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Integrations </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Build Plugins </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/slack-app/" class="sidebar__link">Netlify App for Slack</a></div></li><li class="sidebar__link-item"><div><a href="/integrations/extend-netlify/" class="sidebar__link">Extend Netlify</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Configure & deploy site</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Git </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Environment variables </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Configure builds </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Site deploys </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Domains & HTTPS </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Static routing </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Forms </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Visual editing</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Visual Editor </button> <!----> <!----></section></li><li class="sidebar__link-item"><div><a href="/ai-assisted-publishing/" class="sidebar__link">AI-Assisted Publishing</a></div></li><li class="sidebar__link-item"><div><a href="https://visual-editor-reference.netlify.com/" target="_blank" rel="noopener noreferrer" class="sidebar__link">Visual editor reference</a></div></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Manage data</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Connect </button> <!----> <!----></section></li></ul></div><div class="sidebar__section"><span class="sidebar__section-label">Site & team management</span> <ul class="sidebar__links"><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Accounts & billing </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Security </button> <!----> <!----></section></li><li class="sidebar__link-item"><section tabIndex="-1" class="sidebar__group collapsable is-sub-group"><button tabIndex="-1" class="sidebar__group-heading"> Monitor sites </button> <!----> <!----></section></li></ul></div></div></nav> <div aria-labelledby="#external-link__header" class="external-links" data-v-bad94b42><p id="external-link__header" class="external-links__header" data-v-bad94b42> Contact </p> <ul class="external-links__list" data-v-bad94b42><li class="external-links__item" data-v-bad94b42><a href="https://answers.netlify.com" target="_blank" rel="noopener noreferrer" class="external-links__link" data-v-bad94b42> Forums </a></li> <li class="external-links__item" data-v-bad94b42><a href="https://www.netlify.com/support/" target="_blank" rel="noopener noreferrer" class="external-links__link" data-v-bad94b42> Contact support </a></li></ul></div> <nav aria-label="Netlify navigation" class="navbar__nav is-visible-mamabear navbar__authlinks is-not-visible-mamabear" data-v-1733a580><div class="navbar__nav-list" data-v-1733a580><a href="https://app.netlify.com/login" rel="noopener noreferrer" class="navbar__nav-link" data-v-1733a580> Log in </a> <a href="https://app.netlify.com/signup" target="self" rel="noopener noreferrer" class="navbar__nav-link signup-button" data-v-1733a580> Sign up </a></div></nav></div></div> <div class="wrapper__sidebar wrapper__toc"><nav aria-label="On this page" data-toc="" class="contents wrapper__sidebar-interior"> <details><summary class="contents__header">On this page</summary> <ol><li><a href="/blobs/overview/#overview" data-slug="overview">Overview</a> <!----></li><li><a href="/blobs/overview/#use-cases" data-slug="use-cases">Use cases</a> <!----></li><li><a href="/blobs/overview/#netlify-blobs-api" data-slug="netlify-blobs-api">Netlify Blobs API</a> <ul><li><a href="/blobs/overview/#set" data-slug="set">set</a> <!----></li><li><a href="/blobs/overview/#setjson" data-slug="setjson">setJSON</a> <!----></li><li><a href="/blobs/overview/#get" data-slug="get">get</a> <!----></li><li><a href="/blobs/overview/#getwithmetadata" data-slug="getwithmetadata">getWithMetadata</a> <!----></li><li><a href="/blobs/overview/#getmetadata" data-slug="getmetadata">getMetadata</a> <!----></li><li><a href="/blobs/overview/#list" data-slug="list">list</a> <!----></li><li><a href="/blobs/overview/#liststores" data-slug="liststores">listStores</a> <!----></li><li><a href="/blobs/overview/#delete" data-slug="delete">delete</a> <!----></li></ul></li><li><a href="/blobs/overview/#file-based-uploads" data-slug="file-based-uploads">File-based uploads</a> <!----></li><li><a href="/blobs/overview/#consistency" data-slug="consistency">Consistency</a> <!----></li><li><a href="/blobs/overview/#netlify-blobs-ui" data-slug="netlify-blobs-ui">Netlify Blobs UI</a> <!----></li><li><a href="/blobs/overview/#sensitive-data" data-slug="sensitive-data">Sensitive data</a> <!----></li><li><a href="/blobs/overview/#deploy-specific-stores" data-slug="deploy-specific-stores">Deploy-specific stores</a> <!----></li><li><a href="/blobs/overview/#requirements-and-limitations" data-slug="requirements-and-limitations">Requirements and limitations</a> <!----></li><li><a href="/blobs/overview/#troubleshooting-tips" data-slug="troubleshooting-tips">Troubleshooting tips</a> <!----></li></ol></details></nav></div> <section class="wrapper__content"><header class="content__default"><div class="wrapper__breadcrumbs"><span class="breadcrumb__item"><span>Platform primitives</span> <span class="breadcrumb__break">/</span></span></div> <h1>Netlify Blobs</h1></header> <div class="content__default"><p>With Netlify Blobs, you can store and retrieve <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob" target="_blank" rel="noopener noreferrer">blobs</a> and unstructured data. You can also use this feature as a simple key/value store or basic database.</p> <p>Netlify Blobs is a highly-available data store optimized for frequent reads and infrequent writes.</p> <p>For maximum flexibility, it offers a <a href="/blobs/overview/#consistency">configurable consistency model</a>. If multiple write calls to the same key are issued, the last write wins.</p> <p>We automatically handle provisioning, configuration, and access control for you. This integrated zero-configuration solution helps you focus on building business value in your project rather than toil on setting up and scaling a separate blob storage solution.</p> <h2 id="overview"><a href="#overview" class="header-anchor">#</a> Overview</h2> <p>Each blob belongs to a single site. A site can have multiple namespaces for blobs. We call these <em>stores</em>. This allows you to, for example, have the key <code>nails</code> exist as an object in a store for <code>beauty</code> and separately as an object in a store for <code>construction</code> with different data. Every blob must be associated with a store, even if a site is not using multiple namespaces.</p> <p>You can perform CRUD operations for Netlify Blobs from the following Netlify features:</p> <ul><li><a href="/functions/overview/">Functions</a></li> <li><a href="/edge-functions/overview/">Edge Functions</a></li> <li><a href="/build-plugins/">Build Plugins</a> - note that though a plugin can read from any stores on the site, a plugin can write to only <a href="#deploy-specific-stores">deploy-specific stores</a></li> <li><a href="/cli/get-started/">Netlify CLI</a> - visit the <a href="https://cli.netlify.com/commands/blobs/" target="_blank" rel="noopener noreferrer">CLI command reference</a> for details</li></ul> <p>You can also:</p> <ul><li>write to deploy-specific stores using <a href="#file-based-uploads">file-based uploads</a></li> <li>browse and download blobs in the <a href="#netlify-blobs-ui">Netlify Blobs UI</a></li></ul> <h2 id="use-cases"><a href="#use-cases" class="header-anchor">#</a> Use cases</h2> <p>Netlify Blobs is a platform primitive that developers and frameworks can use as a building block for many different purposes. Here are a few <a href="https://www.netlify.com/blog/introducing-netlify-blobs-beta/" target="_blank" rel="noopener noreferrer">examples of powerful patterns</a> that you can use:</p> <ul><li><strong>Data store for functions.</strong> With <a href="/functions/background-functions/">Background Functions</a>, you can trigger asynchronous serverless workflows for long-running operations like generating a site map, processing media assets, or sending emails in bulk. You can then use Netlify Blobs to persist the output of those computations.</li> <li><strong>Processing user uploads.</strong> If your application takes user submissions, like reviews on a product page or image files for a gallery, Netlify Blobs can store that data. When paired with Functions or Edge Functions, you can create an endpoint to receive an upload, validate the contents, and persist the validated data.</li></ul> <p>For more advanced use cases — such as those that require complex queries, concurrency control, or a relational data model — explore our <a href="https://www.netlify.com/integrations/database-and-backend/" target="_blank" rel="noopener noreferrer">integrations with the best-in-class database vendors</a>.</p> <h2 id="netlify-blobs-api"><a href="#netlify-blobs-api" class="header-anchor">#</a> Netlify Blobs API</h2> <p>To use the Netlify Blobs API, first install the <code>@netlify/blobs</code> module using the <a href="/configure-builds/manage-dependencies/#javascript-dependencies">package manager of your choice</a>:</p> <div class="language-bash extra-class"><pre class="language-bash"><code><span class="token function">npm</span> <span class="token function">install</span> @netlify/blobs </code></pre></div><p>Then use the below methods in your functions, edge functions, or build plugins.</p> <h3 id="set"><a href="#set" class="header-anchor">#</a> <code>set</code></h3> <p>Creates an object with the given key and value. If an entry with the given key already exists, its value is overwritten.</p> <div class="language- extra-class"><pre class="language-text"><code>set(key, value, { metadata? }) </code></pre></div><p>It takes the following parameters:</p> <ul><li><strong><code>key</code>:</strong> a string representing the object key</li> <li><strong><code>value</code>:</strong> the value as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" target="_blank" rel="noopener noreferrer"><code>ArrayBuffer</code></a>, <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob" target="_blank" rel="noopener noreferrer"><code>Blob</code></a>, or string</li> <li><strong><code>metadata</code></strong> (optional)<strong>:</strong> a JSON object with arbitrary metadata to attach to the object</li></ul> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For general carpentry"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For formal events"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> metadata<span class="token operator" data-v-12d54b40>:</span> <span class="token punctuation" data-v-12d54b40>{</span> material<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"acrylic"</span><span class="token punctuation" data-v-12d54b40>,</span> sale<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blobs set for Construction and Beauty stores"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For general carpentry"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For formal events"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> metadata<span class="token operator" data-v-12d54b40>:</span> <span class="token punctuation" data-v-12d54b40>{</span> material<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"acrylic"</span><span class="token punctuation" data-v-12d54b40>,</span> sale<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blobs set for Construction and Beauty stores"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For general carpentry"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For formal events"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>metadata</span><span class="token operator" data-v-12d54b40>:</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>material</span><span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"acrylic"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token literal-property property" data-v-12d54b40>sale</span><span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blobs set for this deploy in Construction and Beauty stores"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <h3 id="setjson"><a href="#setjson" class="header-anchor">#</a> <code>setJSON</code></h3> <p>Convenience method for creating a JSON-serialized object. If an entry with the given key already exists, its value is overwritten.</p> <div class="language- extra-class"><pre class="language-text"><code>setJSON(key, value, { metadata? }) </code></pre></div><p>It takes the following parameters:</p> <ul><li><strong><code>key</code>:</strong> a string representing the object key</li> <li><strong><code>value</code>:</strong> any value that is <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify" target="_blank" rel="noopener noreferrer">serializable to JSON</a></li> <li><strong><code>metadata</code></strong> (optional)<strong>:</strong> a JSON object with arbitrary metadata to attach to the object</li></ul> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>setJSON</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> type<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"common"</span><span class="token punctuation" data-v-12d54b40>,</span> finish<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"bright"</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blob set in JSON for Construction store"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>setJSON</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> type<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"common"</span><span class="token punctuation" data-v-12d54b40>,</span> finish<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"bright"</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blob set in JSON for Construction store"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>setJSON</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>type</span><span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"common"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token literal-property property" data-v-12d54b40>finish</span><span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"bright"</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blob set in JSON for this deploy"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <h3 id="get"><a href="#get" class="header-anchor">#</a> <code>get</code></h3> <p>Retrieves an object with the given key.</p> <div class="language- extra-class"><pre class="language-text"><code>get(key, { consistency?, type? }) </code></pre></div><p>It takes the following parameters:</p> <ul><li><strong><code>key</code>:</strong> a string representing the object key</li> <li><strong><code>consistency</code></strong> (optional)<strong>:</strong> a string representing the <a href="#consistency">consistency model</a> for the operation</li> <li><strong><code>type</code></strong> (optional)<strong>:</strong> the format in which the object should be returned — the default format is a string but you can specify one of the following values instead: <ul><li><strong><code>arrayBuffer</code>:</strong> returns the entry as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" target="_blank" rel="noopener noreferrer"><code>ArrayBuffer</code></a></li> <li><strong><code>blob</code>:</strong> returns the entry as a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob" target="_blank" rel="noopener noreferrer"><code>Blob</code></a></li> <li><strong><code>json</code>:</strong> parses the entry as JSON and returns the resulting object</li> <li><strong><code>stream</code>:</strong> returns the entry as a <a href="https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream" target="_blank" rel="noopener noreferrer"><code>ReadableStream</code></a></li> <li><strong><code>text</code>:</strong> default, returns the entry as a string of plain text</li></ul></li></ul> <p>It returns the blob in the format specified by <code>type</code>. If an object with the given key is not found, <code>null</code> is returned.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry1 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry2 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> text <span class="token operator" data-v-12d54b40>=</span> <span class="token punctuation" data-v-12d54b40>[</span>entry1<span class="token punctuation" data-v-12d54b40>,</span> entry2<span class="token punctuation" data-v-12d54b40>]</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>join</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>" "</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span>text<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry1 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry2 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> text <span class="token operator" data-v-12d54b40>=</span> <span class="token punctuation" data-v-12d54b40>[</span>entry1<span class="token punctuation" data-v-12d54b40>,</span> entry2<span class="token punctuation" data-v-12d54b40>]</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>join</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>" "</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span>text<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry1 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry2 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> text <span class="token operator" data-v-12d54b40>=</span> <span class="token punctuation" data-v-12d54b40>[</span>entry1<span class="token punctuation" data-v-12d54b40>,</span> entry2<span class="token punctuation" data-v-12d54b40>]</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>join</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>" "</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>text<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <h3 id="getwithmetadata"><a href="#getwithmetadata" class="header-anchor">#</a> <code>getWithMetadata</code></h3> <p>Retrieves an object along with its metadata.</p> <div class="language- extra-class"><pre class="language-text"><code>getWithMetadata(key, { consistency?, etag?, type? }) </code></pre></div><p>It takes the following parameters:</p> <ul><li><strong><code>key</code>:</strong> a string representing the object key</li> <li><strong><code>consistency</code></strong> (optional)<strong>:</strong> a string representing the <a href="#consistency">consistency model</a> for the operation</li> <li><strong><code>etag</code></strong> (optional)<strong>:</strong> an opaque quoted string, possibly prefixed by a weakness indicator, representing the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag" target="_blank" rel="noopener noreferrer"><code>ETag</code> value</a> of any version of this blob you may have cached — this allows you to do <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests" target="_blank" rel="noopener noreferrer">conditional requests</a></li> <li><strong><code>type</code></strong> (optional)<strong>:</strong> the format in which the object should be returned — the default format is a string but you can specify one of the following values instead: <ul><li><strong><code>arrayBuffer</code>:</strong> returns the entry as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" target="_blank" rel="noopener noreferrer"><code>ArrayBuffer</code></a></li> <li><strong><code>blob</code>:</strong> returns the entry as a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob" target="_blank" rel="noopener noreferrer"><code>Blob</code></a></li> <li><strong><code>json</code>:</strong> parses the entry as JSON and returns the resulting object</li> <li><strong><code>stream</code>:</strong> returns the entry as a <a href="https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream" target="_blank" rel="noopener noreferrer"><code>ReadableStream</code></a></li> <li><strong><code>text</code>:</strong> default, returns the entry as a string of plain text</li></ul></li></ul> <p>It returns an object with the following properties:</p> <ul><li><strong><code>data</code>:</strong> the blob contents in the format specified by the <code>type</code> parameter, or <code>null</code> if the <code>etag</code> property is the same as the <code>etag</code> parameter (meaning the cached object is still fresh)</li> <li><strong><code>etag</code>:</strong> an opaque quoted string, possibly prefixed by a weakness indicator, representing the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag" target="_blank" rel="noopener noreferrer"><code>ETag</code> value</a> of the object</li> <li><strong><code>metadata</code>:</strong> object with arbitrary metadata</li></ul> <p>If an object with the given key is not found, <code>null</code> is returned.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag<span class="token punctuation" data-v-12d54b40>,</span> metadata <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getWithMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> Response<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>json</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag<span class="token punctuation" data-v-12d54b40>,</span> metadata <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag<span class="token punctuation" data-v-12d54b40>,</span> metadata <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getWithMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> Response<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>json</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag<span class="token punctuation" data-v-12d54b40>,</span> metadata <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getWithMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>data<span class="token punctuation" data-v-12d54b40>,</span> entry<span class="token punctuation" data-v-12d54b40>.</span>etag<span class="token punctuation" data-v-12d54b40>,</span> entry<span class="token punctuation" data-v-12d54b40>.</span>metadata<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <div data-v-b31881da><details class="item" data-v-6824795a><summary class="header" data-v-6824795a><svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down icon-arrow-down" data-v-6824795a><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg> <span data-v-6824795a>Conditional request examples</span></summary> <div class="content" data-v-6824795a><div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token comment" data-v-12d54b40>// Mock implementation of a system for locally persisting blobs and their etags</span> <span class="token keyword" data-v-12d54b40>const</span> cachedETag <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getFromMockCache</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// Get entry from the blob store only if its ETag is different from the one you</span> <span class="token comment" data-v-12d54b40>// have locally, which means the entry has changed since you last retrieved it.</span> <span class="token comment" data-v-12d54b40>// Compare the whole value including surrounding quotes and any weakness prefix.</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getWithMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> etag<span class="token operator" data-v-12d54b40>:</span> cachedETag<span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>etag <span class="token operator" data-v-12d54b40>===</span> cachedETag<span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token comment" data-v-12d54b40>// `data` is `null` because the local blob is fresh</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Still fresh"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token comment" data-v-12d54b40>// `data` contains the new blob, store it locally alongside the new ETag</span> <span class="token function" data-v-12d54b40>writeInMockCache</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Updated"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token comment" data-v-12d54b40>// Mock implementation of a system for locally persisting blobs and their etags</span> <span class="token keyword" data-v-12d54b40>const</span> cachedETag <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getFromMockCache</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// Get entry from the blob store only if its ETag is different from the one you</span> <span class="token comment" data-v-12d54b40>// have locally, which means the entry has changed since you last retrieved it.</span> <span class="token comment" data-v-12d54b40>// Compare the whole value including surrounding quotes and any weakness prefix.</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getWithMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> etag<span class="token operator" data-v-12d54b40>:</span> cachedETag<span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>etag <span class="token operator" data-v-12d54b40>===</span> cachedETag<span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token comment" data-v-12d54b40>// `data` is `null` because the local blob is fresh</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Still fresh"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token comment" data-v-12d54b40>// `data` contains the new blob, store it locally alongside the new ETag</span> <span class="token function" data-v-12d54b40>writeInMockCache</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> data<span class="token punctuation" data-v-12d54b40>,</span> etag<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Updated"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div></div></details></div> <div id="expiration-logic" class="legacy-anchor"></div> <p>You can use object metadata to create client-side expiration logic. To delete blobs you consider expired, do the following:</p> <ol><li><a href="#set"><code>set</code> your objects with metadata</a> that you can base the expiration logic on, such as a timestamp</li> <li><code>getWithMetadata</code> to check if an object is expired</li> <li><a href="#delete"><code>delete</code></a> the expired object</li></ol> <div data-v-b31881da><details class="item" data-v-6824795a><summary class="header" data-v-6824795a><svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down icon-arrow-down" data-v-6824795a><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg> <span data-v-6824795a>Expiration logic examples</span></summary> <div class="content" data-v-6824795a><div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// Set the entry with an `expiration` metadata property</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For formal events"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> metadata<span class="token operator" data-v-12d54b40>:</span> <span class="token punctuation" data-v-12d54b40>{</span> expiration<span class="token operator" data-v-12d54b40>:</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Date</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"2024-01-01"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getTime</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// Read the entry and compare the `expiration` metadata</span> <span class="token comment" data-v-12d54b40>// property against the current timestamp</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getWithMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>entry <span class="token operator" data-v-12d54b40>===</span> <span class="token keyword" data-v-12d54b40>null</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Blob does not exist"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> expiration <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>metadata<span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// If the expiration date is in the future, it means</span> <span class="token comment" data-v-12d54b40>// the blob is still fresh, so return it</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>expiration <span class="token operator" data-v-12d54b40>&&</span> expiration <span class="token operator" data-v-12d54b40><</span> Date<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>now</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>data<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token comment" data-v-12d54b40>// Delete the expired entry</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Blob has expired"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// Set the entry with an `expiration` metadata property</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For formal events"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> metadata<span class="token operator" data-v-12d54b40>:</span> <span class="token punctuation" data-v-12d54b40>{</span> expiration<span class="token operator" data-v-12d54b40>:</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Date</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"2024-01-01"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getTime</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// Read the entry and compare the `expiration` metadata</span> <span class="token comment" data-v-12d54b40>// property against the current timestamp</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getWithMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>entry <span class="token operator" data-v-12d54b40>===</span> <span class="token keyword" data-v-12d54b40>null</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Blob does not exist"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> expiration <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>metadata<span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// If the expiration date is in the future, it means</span> <span class="token comment" data-v-12d54b40>// the blob is still fresh, so return it</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>expiration <span class="token operator" data-v-12d54b40>&&</span> expiration <span class="token operator" data-v-12d54b40><</span> Date<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>now</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>data<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token comment" data-v-12d54b40>// Delete the expired entry</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Blob has expired"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div></div></details></div> <h3 id="getmetadata"><a href="#getmetadata" class="header-anchor">#</a> <code>getMetadata</code></h3> <p>Retrieves the metadata for an object, if the object exists.</p> <p>This method is useful to check if a blob exists without actually retrieving it and having to download a potentially large blob over the network.</p> <div class="language- extra-class"><pre class="language-text"><code>getMetadata(key, { consistency?, etag?, type? }) </code></pre></div><p>It takes the following parameters:</p> <ul><li><strong><code>key</code>:</strong> a string representing the object key</li> <li><strong><code>consistency</code></strong> (optional)<strong>:</strong> a string representing the <a href="#consistency">consistency model</a> for the operation</li> <li><strong><code>etag</code></strong> (optional)<strong>:</strong> an opaque quoted string, possibly prefixed by a weakness indicator, representing the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag" target="_blank" rel="noopener noreferrer"><code>ETag</code> value</a> of any version of this blob you may have cached — this allows you to do <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Conditional_requests" target="_blank" rel="noopener noreferrer">conditional requests</a></li> <li><strong><code>type</code></strong> (optional)<strong>:</strong> the format in which the object should be returned — the default format is a string but you can specify one of the following values instead: <ul><li><strong><code>arrayBuffer</code>:</strong> returns the entry as an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer" target="_blank" rel="noopener noreferrer"><code>ArrayBuffer</code></a></li> <li><strong><code>blob</code>:</strong> returns the entry as a <a href="https://developer.mozilla.org/en-US/docs/Web/API/Blob" target="_blank" rel="noopener noreferrer"><code>Blob</code></a></li> <li><strong><code>json</code>:</strong> parses the entry as JSON and returns the resulting object</li> <li><strong><code>stream</code>:</strong> returns the entry as a <a href="https://developer.mozilla.org/en-US/docs/Web/API/ReadableStream" target="_blank" rel="noopener noreferrer"><code>ReadableStream</code></a></li> <li><strong><code>text</code>:</strong> default, returns the entry as a string of plain text</li></ul></li></ul> <p>It returns an object with the following properties:</p> <ul><li><strong><code>metadata</code>:</strong> object with arbitrary metadata</li> <li><strong><code>etag</code>:</strong> an opaque quoted string, possibly prefixed by a weakness indicator, representing the <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag" target="_blank" rel="noopener noreferrer"><code>ETag</code> value</a> of the object</li></ul> <p>If an object with the given key is not found, <code>null</code> is returned.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>entry <span class="token operator" data-v-12d54b40>===</span> <span class="token keyword" data-v-12d54b40>null</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Blob does not exist"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>return</span> Response<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>json</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> etag<span class="token operator" data-v-12d54b40>:</span> entry<span class="token punctuation" data-v-12d54b40>.</span>etag<span class="token punctuation" data-v-12d54b40>,</span> metadata<span class="token operator" data-v-12d54b40>:</span> entry<span class="token punctuation" data-v-12d54b40>.</span>metadata <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>if</span> <span class="token punctuation" data-v-12d54b40>(</span>entry <span class="token operator" data-v-12d54b40>===</span> <span class="token keyword" data-v-12d54b40>null</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Blob does not exist"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>return</span> Response<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>json</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> etag<span class="token operator" data-v-12d54b40>:</span> entry<span class="token punctuation" data-v-12d54b40>.</span>etag<span class="token punctuation" data-v-12d54b40>,</span> metadata<span class="token operator" data-v-12d54b40>:</span> entry<span class="token punctuation" data-v-12d54b40>.</span>metadata <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>getMetadata</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>etag<span class="token punctuation" data-v-12d54b40>,</span> entry<span class="token punctuation" data-v-12d54b40>.</span>metadata<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <h3 id="list"><a href="#list" class="header-anchor">#</a> <code>list</code></h3> <p>Returns a list of blobs in a given store.</p> <div class="language- extra-class"><pre class="language-text"><code>list({ directories?, paginate?, prefix? }) </code></pre></div><p>It takes the following parameters:</p> <ul><li><strong><code>directories</code></strong> (optional)<strong>:</strong> a boolean that indicates whether keys with the <code>/</code> character should be treated as directories, returning a list of sub-directories at a given level rather than all the keys inside them</li> <li><strong><code>paginate</code></strong> (optional)<strong>:</strong> a boolean that specifies whether you want to <a href="#manual-pagination">handle pagination manually</a> — by default, it is handled automatically</li> <li><strong><code>prefix</code></strong> (optional)<strong>:</strong> a string for filtering down the entries; when specified, only the entries whose key starts with that prefix are returned</li></ul> <p>It returns an object with the following properties:</p> <ul><li><strong><code>blobs</code>:</strong> an array of blobs that match the query parameters, shown as objects with <code>etag</code> and <code>key</code> properties, which represent an object’s <a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag" target="_blank" rel="noopener noreferrer"><code>ETag</code> value</a> and key, respectively</li> <li><strong><code>directories</code>:</strong> an array of strings representing any directories matching the query parameters</li></ul> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag1\"", key: "nails" }, { etag: "W/\"etag2\"", key: "hair" } ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag1\"", key: "nails" }, { etag: "W/\"etag2\"", key: "hair" } ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag1\"", key: "nails" }, { etag: "W/\"etag2\"", key: "hair" } ]</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <p>Optionally, you can group blobs together under a common prefix and then browse them hierarchically when listing a store. This is similar to grouping files in a directory. To browse hierarchically, do the following:</p> <ol><li>Group keys hierarchically with the <code>/</code> character in your key names.</li> <li>List entries hierarchically with the <code>directories</code> parameter.</li> <li>Drill down into a specific directory with the <code>prefix</code> parameter.</li></ol> <div data-v-b31881da><details class="item" data-v-6824795a><summary class="header" data-v-6824795a><svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down icon-arrow-down" data-v-6824795a><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg> <span data-v-6824795a>Hierarchical browsing examples</span></summary> <div class="content" data-v-6824795a><p data-v-6824795a>Take the following set of keys as an example:</p> <div class="language- extra-class" data-v-6824795a><pre class="language-text" data-v-6824795a><code data-v-6824795a>cats/shorthair.jpg cats/longhair.jpg dogs/beagle.jpg dogs/corgi.jpg bird.jpg </code></pre></div><p data-v-6824795a>By default, <code data-v-6824795a>list</code> will return all five keys.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag1\"", key: "cats/shorthair.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag2\"", key: "cats/longhair.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag3\"", key: "dogs/beagle.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag4\"", key: "dogs/corgi.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag5\"", key: "bird.jpg" },</span> <span class="token comment" data-v-12d54b40>// ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag1\"", key: "cats/shorthair.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag2\"", key: "cats/longhair.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag3\"", key: "dogs/beagle.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag4\"", key: "dogs/corgi.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag5\"", key: "bird.jpg" },</span> <span class="token comment" data-v-12d54b40>// ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag1\"", key: "cats/shorthair.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag2\"", key: "cats/longhair.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag3\"", key: "dogs/beagle.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag4\"", key: "dogs/corgi.jpg" },</span> <span class="token comment" data-v-12d54b40>// { etag: "\"etag5\"", key: "bird.jpg" },</span> <span class="token comment" data-v-12d54b40>// ]</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <p data-v-6824795a>To list entries hierarchically, set the <code data-v-6824795a>directories</code> parameter to <code data-v-6824795a>true</code>.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs<span class="token punctuation" data-v-12d54b40>,</span> directories <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> directories<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag5\"", key: "bird.jpg" } ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ "cats", "dogs" ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>directories<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs and </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>directories<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> directories</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs<span class="token punctuation" data-v-12d54b40>,</span> directories <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> directories<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag5\"", key: "bird.jpg" } ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ "cats", "dogs" ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>directories<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs and </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>directories<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> directories</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs<span class="token punctuation" data-v-12d54b40>,</span> directories <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>directories</span><span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag5\"", key: "bird.jpg" } ]</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ "cats", "dogs" ]</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>directories<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <p data-v-6824795a>To drill down into a directory and get a list of its items, set the <code data-v-6824795a>prefix</code> parameter to the directory name.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs<span class="token punctuation" data-v-12d54b40>,</span> directories <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> directories<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span><span class="token punctuation" data-v-12d54b40>,</span> prefix<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"cats/"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag1\"", key: "cats/shorthair.jpg" }, { etag: "\"etag2\"", key: "cats/longhair.jpg" } ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>directories<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs and </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>directories<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> directories</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs<span class="token punctuation" data-v-12d54b40>,</span> directories <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> directories<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span><span class="token punctuation" data-v-12d54b40>,</span> prefix<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"cats/"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag1\"", key: "cats/shorthair.jpg" }, { etag: "\"etag2\"", key: "cats/longhair.jpg" } ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>directories<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs and </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>directories<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> directories</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> animals <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> blobs<span class="token punctuation" data-v-12d54b40>,</span> directories <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> animals<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>directories</span><span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token literal-property property" data-v-12d54b40>prefix</span><span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"cats/"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ { etag: "\"etag1\"", key: "cats/shorthair.jpg" }, { etag: "\"etag2\"", key: "cats/longhair.jpg" } ]</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ ]</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>directories<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <p data-v-6824795a>Note that the prefix includes a trailing slash. This ensures that only entries under the <code data-v-6824795a>cats</code> directory are returned. Without a trailing slash, other keys like <code data-v-6824795a>catsuit</code> would also be returned.</p></div></details></div> <div id="manual-pagination" class="legacy-anchor"></div> <p>For performance reasons, the server groups results into pages of up to 1,000 entries. By default, the <code>list</code> method automatically retrieves all pages, meaning you’ll always get the full list of results.</p> <p>To handle pagination manually, set the <code>paginate</code> parameter to <code>true</code>. This makes <code>list</code> return an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator" target="_blank" rel="noopener noreferrer"><code>AsyncIterator</code></a>, which lets you take full control over the pagination process. This means you can fetch only the data you need when you need it.</p> <div data-v-b31881da><details class="item" data-v-6824795a><summary class="header" data-v-6824795a><svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down icon-arrow-down" data-v-6824795a><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg> <span data-v-6824795a>Manual blob pagination examples</span></summary> <div class="content" data-v-6824795a><div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>let</span> blobCount <span class="token operator" data-v-12d54b40>=</span> <span class="token number" data-v-12d54b40>0</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>for</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token keyword" data-v-12d54b40>const</span> entry <span class="token keyword" data-v-12d54b40>of</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> paginate<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> blobCount <span class="token operator" data-v-12d54b40>+=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token punctuation" data-v-12d54b40>;</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobCount<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>let</span> blobCount <span class="token operator" data-v-12d54b40>=</span> <span class="token number" data-v-12d54b40>0</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>for</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token keyword" data-v-12d54b40>const</span> entry <span class="token keyword" data-v-12d54b40>of</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> paginate<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> blobCount <span class="token operator" data-v-12d54b40>+=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token punctuation" data-v-12d54b40>;</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobCount<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>let</span> blobCount <span class="token operator" data-v-12d54b40>=</span> <span class="token number" data-v-12d54b40>0</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>for</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token keyword" data-v-12d54b40>const</span> entry <span class="token keyword" data-v-12d54b40>of</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>list</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>paginate</span><span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> blobCount <span class="token operator" data-v-12d54b40>+=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>blobs<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>blobs<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>blobCount<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> blobs</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div></div></details></div> <h3 id="liststores"><a href="#liststores" class="header-anchor">#</a> <code>listStores</code></h3> <p>Returns a list of stores for a site. Does not include <a href="/blobs/overview/#deploy-specific-stores">deploy-specific stores</a>.</p> <div class="language- extra-class"><pre class="language-text"><code>listStores({ paginate? }) </code></pre></div><p>It takes the following parameter:</p> <ul><li><strong><code>paginate</code></strong> (optional)<strong>:</strong> a boolean that specifies whether you want to <a href="#manual-store-pagination">handle pagination manually</a> — by default, it is handled automatically</li></ul> <p>It returns an object with the following array:</p> <ul><li><strong><code>stores</code>:</strong> an array of strings representing any stores matching the query parameters</li></ul> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> listStores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> stores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token function" data-v-12d54b40>listStores</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ "beauty", "construction" ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>stores<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>stores<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> stores</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> listStores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> stores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token function" data-v-12d54b40>listStores</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ "beauty", "construction" ]</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>stores<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>stores<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> stores</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> listStores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> stores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token function" data-v-12d54b40>listStores</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// [ "beauty", "construction" ]</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>stores<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <div id="manual-store-pagination" class="legacy-anchor"></div> <p>For performance reasons, the server groups results into pages of up to 1,000 stores. By default, the <code>listStores</code> method automatically retrieves all pages, meaning you’ll always get the full list of results.</p> <p>To handle pagination manually, set the <code>paginate</code> parameter to <code>true</code>. This makes <code>listStores</code> return an <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AsyncIterator" target="_blank" rel="noopener noreferrer"><code>AsyncIterator</code></a>, which lets you take full control over the pagination process. This means you can fetch only the data you need when you need it.</p> <div data-v-b31881da><details class="item" data-v-6824795a><summary class="header" data-v-6824795a><svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down icon-arrow-down" data-v-6824795a><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg> <span data-v-6824795a>Manual store pagination examples</span></summary> <div class="content" data-v-6824795a><div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> listStores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>let</span> storeCount <span class="token operator" data-v-12d54b40>=</span> <span class="token number" data-v-12d54b40>0</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>for</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token keyword" data-v-12d54b40>const</span> entry <span class="token keyword" data-v-12d54b40>of</span> <span class="token function" data-v-12d54b40>listStores</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> paginate<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> storeCount <span class="token operator" data-v-12d54b40>+=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>stores<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token punctuation" data-v-12d54b40>;</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>stores<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>storeCount<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> stores</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> listStores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>let</span> storeCount <span class="token operator" data-v-12d54b40>=</span> <span class="token number" data-v-12d54b40>0</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>for</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token keyword" data-v-12d54b40>const</span> entry <span class="token keyword" data-v-12d54b40>of</span> <span class="token function" data-v-12d54b40>listStores</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> paginate<span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> storeCount <span class="token operator" data-v-12d54b40>+=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>stores<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token punctuation" data-v-12d54b40>;</span> <span class="token builtin" data-v-12d54b40>console</span><span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>stores<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>storeCount<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> stores</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> listStores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token punctuation" data-v-12d54b40>{</span> stores <span class="token punctuation" data-v-12d54b40>}</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token function" data-v-12d54b40>listStores</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>paginate</span><span class="token operator" data-v-12d54b40>:</span> <span class="token boolean" data-v-12d54b40>true</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>let</span> storeCount <span class="token operator" data-v-12d54b40>=</span> <span class="token number" data-v-12d54b40>0</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>for</span> <span class="token keyword" data-v-12d54b40>await</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token keyword" data-v-12d54b40>const</span> entry <span class="token keyword" data-v-12d54b40>of</span> stores<span class="token punctuation" data-v-12d54b40>)</span> <span class="token punctuation" data-v-12d54b40>{</span> storeCount <span class="token operator" data-v-12d54b40>+=</span> entry<span class="token punctuation" data-v-12d54b40>.</span>stores<span class="token punctuation" data-v-12d54b40>.</span>length<span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>.</span>stores<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token template-string" data-v-12d54b40><span class="token template-punctuation string" data-v-12d54b40>`</span><span class="token string" data-v-12d54b40>Found </span><span class="token interpolation" data-v-12d54b40><span class="token interpolation-punctuation punctuation" data-v-12d54b40>${</span>storeCount<span class="token interpolation-punctuation punctuation" data-v-12d54b40>}</span></span><span class="token string" data-v-12d54b40> stores</span><span class="token template-punctuation string" data-v-12d54b40>`</span></span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div></div></details></div> <h3 id="delete"><a href="#delete" class="header-anchor">#</a> <code>delete</code></h3> <p>Deletes an object with the given key, if one exists.</p> <div class="language- extra-class"><pre class="language-text"><code>delete(key) </code></pre></div><p>It takes the following parameters:</p> <ul><li><strong><code>key</code>:</strong> a string representing the object key</li></ul> <p>The return value is always <code>undefined</code>, regardless of whether an object was actually deleted.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blobs deleted from Construction and Beauty stores"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blobs deleted from Construction and Beauty stores"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> beauty <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"beauty"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> beauty<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>delete</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blobs deleted for this deploy from Construction and Beauty stores"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <h2 id="file-based-uploads"><a href="#file-based-uploads" class="header-anchor">#</a> File-based uploads</h2> <p>With file-based uploads, you can write blobs to <a href="#deploy-specific-stores">deploy-specific stores</a> after the build completes and before the deploy starts. This can be useful for authors of frameworks and other tools integrating with Netlify as it does not require a build plugin.</p> <p>To make file-based uploads, place blob files in <code>.netlify/blobs/deploy</code> in your site’s <a href="/configure-builds/overview/#definitions">base directory</a>. Netlify uploads these files to blob storage maintaining their directory structure. Here is an example file tree:</p> <div class="language- extra-class"><pre class="language-text"><code>.netlify/ ├─ blobs/ | ├─ deploy/ │ | ├─ beauty/ │ │ | └─ nails.jpg │ | ├─ construction/ │ │ | └─ nails.jpg │ | └─ dog.jpg </code></pre></div><p>This uploads the following blobs:</p> <ul><li><code>beauty/nails.jpg</code></li> <li><code>construction/nails.jpg</code></li> <li><code>dog.jpg</code></li></ul> <p>To attach metadata to a blob, include a JSON file that prefixes the corresponding blob filename with <code>$</code> and has a <code>.json</code> extension. For example:</p> <div class="language- extra-class"><pre class="language-text"><code>.netlify/ ├─ blobs/ | ├─ deploy/ │ | ├─ beauty/ │ │ | ├─ nails.jpg │ │ | └─ $nails.jpg.json │ | ├─ construction/ │ │ | └─ nails.jpg │ | ├─ dog.jpg │ | ├─ mouse.jpg │ | └─ $mouse.jpg.json </code></pre></div><p>This uploads the following blobs:</p> <ul><li><code>beauty/nails.jpg</code> with the metadata from <code>beauty/$nails.jpg.json</code></li> <li><code>construction/nails.jpg</code> without metadata</li> <li><code>dog.jpg</code> without metadata</li> <li><code>mouse.jpg</code> with the metadata from <code>$mouse.jpg.json</code></li></ul> <p>Metadata files must contain valid JSON or the deploy will fail. Here’s an example of valid JSON metadata:</p> <div class="language-json extra-class"><pre class="language-json"><code><span class="token punctuation">{</span> <span class="token property">"type"</span><span class="token operator">:</span> <span class="token string">"common"</span><span class="token punctuation">,</span> <span class="token property">"finish"</span><span class="token operator">:</span> <span class="token string">"bright"</span> <span class="token punctuation">}</span> </code></pre></div><h2 id="consistency"><a href="#consistency" class="header-anchor">#</a> Consistency</h2> <p>By default, the Netlify Blobs API uses an <a href="https://en.wikipedia.org/wiki/Eventual_consistency" target="_blank" rel="noopener noreferrer">eventual consistency</a> model, where data is stored in a single region and cached at the edge for fast access across the globe. When a blob is added, it becomes globally available immediately. Updates and deletions are guaranteed to be propagated to all edge locations within 60 seconds.</p> <p>You can configure this behavior and opt-in to strong consistency with the <a href="#netlify-blobs-api">Netlify Blobs API</a>, either for an entire store or for individual read operations. <a href="https://cli.netlify.com/commands/blobs/" target="_blank" rel="noopener noreferrer">Netlify CLI</a> always uses strong consistency.</p> <p>Choosing the right consistency model depends on your use case and each option comes with tradeoffs:</p> <ul><li>if it’s important for your application that updates and deletions become immediately available to all readers, you should consider using <code>strong</code> consistency, which comes with the cost of slower reads</li> <li>if that is not a hard requirement and you’re optimizing for fast reads, you should consider using <code>eventual</code> consistency</li></ul> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="store-level-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> name<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>,</span> consistency<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"strong"</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"dog"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"🐶"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// This is a strongly-consistent read.</span> <span class="token keyword" data-v-12d54b40>const</span> dog <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"dog"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span>dog<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="operation-level-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"animals"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"dog"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"🐶"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// This is an eventually-consistent read.</span> <span class="token keyword" data-v-12d54b40>const</span> dog1 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"dog"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token comment" data-v-12d54b40>// This is a strongly-consistent read.</span> <span class="token keyword" data-v-12d54b40>const</span> dog2 <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"dog"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token punctuation" data-v-12d54b40>{</span> consistency<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"strong"</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span>dog1 <span class="token operator" data-v-12d54b40>+</span> dog2<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <h2 id="netlify-blobs-ui"><a href="#netlify-blobs-ui" class="header-anchor">#</a> Netlify Blobs UI</h2> <p>In addition to using the Netlify Blobs API to <a href="#list">list</a> and <a href="#get">get</a> blobs, you can use the Netlify UI to browse and download blobs.</p> <p>To explore and retrieve your site’s blobs:</p> <ol><li><p>In the Netlify UI, go to the <div aria-label="Navigation path" class="nav-path-container"><strong>Blobs</strong></div> page for your site.</p></li> <li><p>If your site has more than one store, select the store of interest.</p> <p><img src="/images/blobs-select-store.png" alt=""></p></li> <li><p>Then, drill into directories to explore the blobs in the store or <strong>Download</strong> an individual blob to examine it.</p></li></ol> <h2 id="sensitive-data"><a href="#sensitive-data" class="header-anchor">#</a> Sensitive data</h2> <p>You can store sensitive data with Netlify Blobs. To keep your data secure, we encrypt your blobs at rest and in transit.</p> <p>Your blobs can only be accessed through your own site. You are responsible for making sure the code you use to access your blobs doesn’t allow data to leak. We recommend that you consider the following best practices:</p> <ul><li>Do not allow incoming requests for arbitrary keys if you have sensitive data. Treat user input as unsafe and scope your keys with something that callers cannot tamper with.</li> <li>Review the code of any <a href="/build-plugins/#file-based-installation">build plugin you install from the npm public registry</a> to make sure it doesn’t have malicious blob interactions.</li></ul> <p>Visit our <a href="/platform/security-checklist/#recommended-security-measures">security checklist</a> for general security measures we recommend you consider for your site.</p> <h2 id="deploy-specific-stores"><a href="#deploy-specific-stores" class="header-anchor">#</a> Deploy-specific stores</h2> <p>The namespaces you make with <code>getStore</code> are shared across all deploys of your site. This is required when using Netlify CLI and desirable for most use cases with functions and edge functions because it means that a new production deploy can read previously written data without you having to replicate blobs for each new production deploy. This also means you can test your Deploy Previews with production data. This does, however, mean that you should be careful to avoid scenarios such as a branch deploy deleting blobs that your published deploy depends on.</p> <p>As mentioned above, build plugins and file-based uploads must write to deploy-specific stores. This requirement makes it so that a deploy that fails cannot overwrite production data.</p> <p>To make a deploy-specific namespace with the Netlify Blobs API, use the <code>getDeployStore</code> method.</p> <div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For general carpentry"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blob set for this deploy"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="edge-function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/edge-functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For general carpentry"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blob set for this deploy"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> store <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>await</span> store<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>set</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>,</span> <span class="token string" data-v-12d54b40>"For general carpentry"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"Nail blob set for this deploy"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div> <p>In general, blobs in deploy-specific stores are managed by Netlify like other atomic deploy assets. This means they’re kept in sync with their relative deploys if you do a <a href="/site-deploys/manage-deploys/#rollbacks">rollback</a> and that they’re cleaned up with <a href="/site-deploys/manage-deploys/#automatic-deploy-deletion">automatic deploy deletion</a>.</p> <p>However, <a href="/site-deploys/manage-deploys/#download-a-deploy">downloading a deploy</a> does not download deploy-specific blobs, and <a href="/site-deploys/manage-deploys/#lock-a-published-deploy">locking a published deploy</a> does not prevent you from writing to associated deploy-specific stores.</p> <h2 id="requirements-and-limitations"><a href="#requirements-and-limitations" class="header-anchor">#</a> Requirements and limitations</h2> <p>Keep the following requirements in mind while working with Netlify Blobs:</p> <ul><li>Netlify Blobs uses the <a href="https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API" target="_blank" rel="noopener noreferrer">web platform <code>fetch()</code></a> to make HTTP calls, so Fetch API support is required. This is included with Node.js 18. If for some reason you can’t use Node.js 18, you can provide your own Fetch API support by supplying a <code>fetch</code> property to the <code>getStore</code> or <code>getDeployStore</code> method.</li> <li>File-based uploads require <a href="/site-deploys/create-deploys/#deploy-with-git">continuous deployment</a> or <a href="/cli/get-started/#manual-deploys">CLI deploys</a>.</li></ul> <div data-v-b31881da><details class="item" data-v-6824795a><summary class="header" data-v-6824795a><svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down icon-arrow-down" data-v-6824795a><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg> <span data-v-6824795a>Custom fetch examples</span></summary> <div class="content" data-v-6824795a><div class="theme-code-group" data-v-5f0a03e0><div class="theme-code-group__nav" data-v-5f0a03e0><ul role="tablist" class="theme-code-group__ul" data-v-5f0a03e0><li class="theme-code-group__li" data-v-5f0a03e0><button class="theme-code-group__nav-tab" data-v-5f0a03e0> Loading error: Refresh the page to access this code sample </button></li></ul></div> <div role="tabpanel" id="function-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-ts extra-class" data-v-12d54b40><pre class="language-ts" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> fetch <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"whatwg-fetch"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token keyword" data-v-12d54b40>type</span> <span class="token punctuation" data-v-12d54b40>{</span> Context <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/functions"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>default</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span>req<span class="token operator" data-v-12d54b40>:</span> Request<span class="token punctuation" data-v-12d54b40>,</span> context<span class="token operator" data-v-12d54b40>:</span> Context<span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> fetch<span class="token punctuation" data-v-12d54b40>,</span> name<span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"construction"</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>return</span> <span class="token keyword" data-v-12d54b40>new</span> <span class="token class-name" data-v-12d54b40>Response</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div> <div role="tabpanel" id="build-plugin-tab" tabindex="0" class="theme-code-block" data-v-12d54b40><div class="language-js extra-class" data-v-12d54b40><pre class="language-js" data-v-12d54b40><code data-v-12d54b40><span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> fetch <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"whatwg-fetch"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>import</span> <span class="token punctuation" data-v-12d54b40>{</span> getDeployStore <span class="token punctuation" data-v-12d54b40>}</span> <span class="token keyword" data-v-12d54b40>from</span> <span class="token string" data-v-12d54b40>"@netlify/blobs"</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>export</span> <span class="token keyword" data-v-12d54b40>const</span> <span class="token function-variable function" data-v-12d54b40>onPostBuild</span> <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>async</span> <span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>)</span> <span class="token operator" data-v-12d54b40>=></span> <span class="token punctuation" data-v-12d54b40>{</span> <span class="token keyword" data-v-12d54b40>const</span> construction <span class="token operator" data-v-12d54b40>=</span> <span class="token function" data-v-12d54b40>getDeployStore</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token punctuation" data-v-12d54b40>{</span> <span class="token literal-property property" data-v-12d54b40>name</span><span class="token operator" data-v-12d54b40>:</span> <span class="token string" data-v-12d54b40>"construction"</span><span class="token punctuation" data-v-12d54b40>,</span> fetch <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token keyword" data-v-12d54b40>const</span> entry <span class="token operator" data-v-12d54b40>=</span> <span class="token keyword" data-v-12d54b40>await</span> construction<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>get</span><span class="token punctuation" data-v-12d54b40>(</span><span class="token string" data-v-12d54b40>"nails"</span><span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> console<span class="token punctuation" data-v-12d54b40>.</span><span class="token function" data-v-12d54b40>log</span><span class="token punctuation" data-v-12d54b40>(</span>entry<span class="token punctuation" data-v-12d54b40>)</span><span class="token punctuation" data-v-12d54b40>;</span> <span class="token punctuation" data-v-12d54b40>}</span><span class="token punctuation" data-v-12d54b40>;</span> </code></pre></div></div></div></div></details></div> <p>Keep the following rules in mind when creating namespaces and blobs:</p> <ul><li>Store names cannot include the <code>/</code> character.</li> <li>Store names cannot include the <code>:</code> character.</li> <li>Store names cannot exceed 64 bytes.</li> <li>Empty keys are not supported.</li> <li>Object keys can include any Unicode characters.</li> <li>Object keys cannot start with the <code>/</code> character.</li> <li>Object keys cannot exceed 600 bytes.</li> <li>An individual object’s total size cannot exceed 5 GB.</li> <li>An individual object’s metadata size cannot exceed 2 KB.</li></ul> <div class="custom-block netlify-tip"><p class="custom-block-title">Most characters use 1 byte</p> <p>Most Unicode characters with UTF-8 encoding take 1 byte. So, for convenience, you can think of the above size limits as roughly a 64-character limit for store names and a 600-character limit for object keys. But, be aware that some characters take more than one byte. For example, <code>à</code> takes 2 bytes.</p></div> <p>Keep the following limitations in mind when working with Netlify Blobs:</p> <ul><li>Functions written in Go cannot access Netlify Blobs.</li> <li>Cross-site blob access is not allowed. To share data between sites, you can use a <a href="/routing/redirects/rewrites-proxies/">rewrite</a> on site A to a path on site B that pulls data from site B’s blobs.</li> <li>Local development with Netlify Dev uses a sandboxed local store that does not support <a href="#file-based-uploads">file-based uploads</a>. You cannot read production data during local development.</li> <li><a href="/site-deploys/manage-deploys/#automatic-deploy-deletion">Deploy deletion</a> deletes deploy-specific stores only. For other stores, you can create <a href="#expiration-logic">custom expiration logic</a> or <a href="#delete">delete objects manually</a> as needed.</li> <li>Netlify Blobs is not currently supported as part of our HIPAA-compliant hosting offering. For more information, visit our <a href="https://trust-center.netlify-corp.com" target="_blank" rel="noopener noreferrer">Trust Center</a> and download our reference architecture for HIPAA-compliant composable sites on Netlify.</li></ul> <h2 id="troubleshooting-tips"><a href="#troubleshooting-tips" class="header-anchor">#</a> Troubleshooting tips</h2> <ul><li><p><strong>Last write wins.</strong> If two overlapping calls try to write the same object, the last write wins. Netlify Blobs does not include a concurrency control mechanism. To manage the potential for race conditions, you can build an object-locking mechanism into your application.</p></li> <li><p><strong>Store access depends on <code>@netlify/blobs</code> module version.</strong> If you wrote to site-wide stores with <code>@netlify/blobs</code> version 6.5.0 or earlier, and you then upgrade the module to a more recent version, you will no longer be able to access data in those stores. This is due to an internal change to namespacing logic. You can migrate affected stores by running the following command in the project directory using the latest version of the <a href="/cli/get-started/">Netlify CLI</a>.</p> <div class="language-sh extra-class"><pre class="language-sh"><code>netlify recipes blobs-migrate YOUR_STORE_NAME </code></pre></div><p>This makes the migrated store accessible with <code>@netlify/blobs</code> module version 7.0.0 and later.</p></li></ul></div> <!----> <div class="content__default wrapper__last_updated"><time datetime="2024-10-02"> Last updated: October 2, 2024 </time></div> <!----> <div class="feedback"><div class="media"><div class="media__body"><h4 class="media__title"> Did you find this doc useful? </h4> <!----> <p class="media__copy"> Your feedback helps us improve our docs. </p> <!----> <!----></div> <div class="media__figure"><button aria-label="upvote" class="feedback__vote feedback__vote--upvote"><svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" aria-hidden="true"><g fill="none" fill-rule="evenodd"><circle cx="32" cy="32" r="32" fill="none" fill-rule="nonzero"></circle> <g stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M40 29h-7.645l1.473-3.889c.377-.996.042-2.135-.803-2.73-.963-.679-2.263-.427-2.936.569L26 29v9a4 4 0 0 0 4 4h6.517c1.51 0 2.893-.852 3.573-2.203L42 36v-5a2 2 0 0 0-2-2zM22 29v12"></path></g></g></svg></button><button aria-label="downvote" class="feedback__vote feedback__vote--downvote"><svg xmlns="http://www.w3.org/2000/svg" width="64" height="64" aria-hidden="true"><g fill="none" fill-rule="evenodd"><circle cx="32" cy="32" r="32" fill="none" fill-rule="nonzero"></circle> <g stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"><path d="M23 35h7.645l-1.473 3.889c-.377.996-.042 2.135.803 2.73.963.679 2.263.427 2.936-.569l4.09-6.05v-9a4 4 0 0 0-4-4h-6.518c-1.51 0-2.893.852-3.573 2.202L21 28v5a2 2 0 0 0 2 2zM41 35V23"></path></g></g></svg></button></div></div> <div><form class='form form--floating-labels feedback__form--appear' method='post' name='feedback'><input type="hidden" name="form-name" value="feedback"> <input type="hidden" name="path" value="/blobs/overview/"> <input type="hidden" name="vote" value=""> <label class="visuallyhidden"> Do not fill in this field <input name="verification" value=""></label> <div class="form__field"><label><div class="form__label"> What else would you like to tell us about this doc? </div> <textarea name="feedback" class="form__textarea"></textarea></label></div> <div class="btn-group"><button disabled="disabled" class="btn"> Send </button></div></form></div></div> <footer class="footer"><div class="footer-wrapper"><nav aria-label="Footer navigation" class="footer-nav"><ul class="footer__nav"><li class="footer__nav-item"><a href="https://netlify.com/" class="footer__nav-link"> Netlify </a></li> <li class="footer__nav-item"><a href="https://netlify.com/careers/" class="footer__nav-link"> Careers </a></li> <li class="footer__nav-item"><a href="https://netlify.com/blog/" class="footer__nav-link"> Blog </a></li> <li class="footer__nav-item"><a href="https://www.netlify.com/legal/terms-of-use/" class="footer__nav-link"> Terms </a></li> <li class="footer__nav-item"><a href="https://www.netlify.com/privacy/" class="footer__nav-link"> Privacy </a></li></ul></nav> <div class="dark-mode-widget footer__theme-toggle" data-v-0d17f8d5><label for="theme-select" class="visuallyhidden" data-v-0d17f8d5>Select a theme</label> <div class="forms-select-c" data-v-0d17f8d5><div class="theme-toggle-icon" data-v-0d17f8d5><svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg" data-v-0d17f8d5><path fill-rule="evenodd" clip-rule="evenodd" d="M14 7C14 10.866 10.866 14 7 14C3.13401 14 0 10.866 0 7C0 3.13401 3.13401 0 7 0C10.866 0 14 3.13401 14 7ZM7 12.2C6.99999 12.2 7.00001 12.2 7 12.2C4.12812 12.2 1.8 9.87188 1.8 7C1.8 4.12812 4.12812 1.8 7 1.8C7.00001 1.8 6.99999 1.8 7 1.8V12.2Z" fill="currentColor"></path></svg> <!----> <!----></div> <select value="system" name="theme-select" id="theme-select" class="forms-input"> <option value="system" data-v-0d17f8d5>System</option><option value="light" data-v-0d17f8d5>Light</option><option value="dark" data-v-0d17f8d5>Dark</option></select> <svg width="21" height="13" viewBox="0 0 21 13" fill="none" xmlns="http://www.w3.org/2000/svg" class="icon-arrow-down forms-select-c-arrow"><path d="M20.7656 1.82812C21.0156 2.10938 21.0156 2.375 20.7656 2.625L10.9219 12.4688C10.6719 12.7188 10.4219 12.7188 10.1719 12.4688L0.328125 2.625C0.078125 2.375 0.078125 2.10938 0.328125 1.82812L1.26562 0.9375C1.51562 0.65625 1.78125 0.65625 2.0625 0.9375L10.5469 9.375L19.0312 0.9375C19.3125 0.65625 19.5781 0.65625 19.8281 0.9375L20.7656 1.82812Z"></path></svg></div></div></div> <p class="footer__copyright">© 2024 Netlify</p></footer></section></main></div><div class="global-ui"></div></div> <script src="/assets/js/app.cc2f9ad6.js" defer></script><script src="/assets/js/10.a8fb7bb3.js" defer></script><script src="/assets/js/2.01499542.js" defer></script><script src="/assets/js/44.d25d9ab0.js" defer></script><script src="/assets/js/16.dc8f34ea.js" defer></script><script src="/assets/js/15.6d589b72.js" defer></script><script src="/assets/js/21.29480efd.js" defer></script><script src="/assets/js/11.470e17cb.js" defer></script><script src="/assets/js/9.ad446dfa.js" defer></script><script src="/assets/js/3.9ee141f4.js" defer></script> <script src="/netlify-cnm/cnm.js" async defer></script> <script async id="netlify-rum-container" src="/.netlify/scripts/rum" data-netlify-rum-site-id="90a54386-9477-4113-bd6a-b9227b573d00" data-netlify-deploy-branch="main" data-netlify-deploy-context="production" data-netlify-cwv-token="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzaXRlX2lkIjoiOTBhNTQzODYtOTQ3Ny00MTEzLWJkNmEtYjkyMjdiNTczZDAwIiwiYWNjb3VudF9pZCI6IjU4ZGE4ODkzZDY4NjVkMzVjOTJhNzJiOCIsImRlcGxveV9pZCI6IjY3NDYyNTk0MTY2YmQ1MDAwOGJkMjJiOCIsImlzc3VlciI6Im5mc2VydmVyIn0.5JYS7P1qEHDOiNJnm4w671aLfC1I2tJgug7qA8UN6IM"></script><script type="text/javascript"> if (window.location.host === "docs.netlify.com") { !function(){var analytics=window.analytics=window.analytics||[];if(!analytics.initialize)if(analytics.invoked)window.console&&console.error&&console.error("Segment snippet included twice.");else{analytics.invoked=!0;analytics.methods=["trackSubmit","trackClick","trackLink","trackForm","pageview","identify","reset","group","track","ready","alias","debug","page","once","off","on","addSourceMiddleware","addIntegrationMiddleware","setAnonymousId","addDestinationMiddleware"];analytics.factory=function(e){return function(){var t=Array.prototype.slice.call(arguments);t.unshift(e);analytics.push(t);return analytics}};for(var e=0;e<analytics.methods.length;e++){var key=analytics.methods[e];analytics[key]=analytics.factory(key)}analytics.load=function(key,e){var t=document.createElement("script");t.type="text/javascript";t.async=!0;t.src="https://cdn.segment.com/analytics.js/v1/" + key + "/analytics.min.js";var n=document.getElementsByTagName("script")[0];n.parentNode.insertBefore(t,n);analytics._loadOptions=e};analytics.SNIPPET_VERSION="4.13.1"; analytics.load("kjz0qkJslzzHMcNGI3GkDb9HDZ6vspYZ"); }}(); } </script></body> </html>