https://subtle-crepe-f83d81.netlify.app/
i am able to write to the blob from the command line
netlify blobs:set clouds file1.txt 11111111111111
but when i try a function (which is copied from the example in the docs) i get this error: accept: ‘text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7’,
‘accept-encoding’: ‘br’,
‘accept-language’: ‘en-US,en;q=0.9’,
‘cache-control’: ‘max-age=0’,
‘cdn-loop’: ‘netlify’,
dnt: ‘1’,
host: ‘subtle-crepe-f83d81.netlify.app’,
priority: ‘u=0, i’,
‘sec-ch-ua’: ‘“Not/A)Brand”;v=“8”, “Chromium”;v=“126”, “Google Chrome”;v=“126”’,
‘sec-ch-ua-mobile’: ‘?0’,
‘sec-ch-ua-platform’: ‘“Windows”’,
‘sec-fetch-dest’: ‘document’,
‘sec-fetch-mode’: ‘navigate’,
‘sec-fetch-site’: ‘none’,
‘sec-fetch-user’: ‘?1’,
‘upgrade-insecure-requests’: ‘1’,
‘user-agent’: ‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36’,
‘x-country’: ‘US’,
‘x-forwarded-for’: ‘2601:1c0:847e:6b50:bcb3:1655:9ba3:62cc’,
‘x-forwarded-proto’: ‘https’,
‘x-language’: ‘en-US’,
‘x-nf-account-id’: ‘667d92ffca7a2b26fa962351’,
‘x-nf-client-connection-ip’: ‘2601:1c0:847e:6b50:bcb3:1655:9ba3:62cc’,
‘x-nf-deploy-id’: ‘6682f384a469ba6fd3ab61f9’,
‘x-nf-geo’: ‘eyJjaXR5IjoiQ29ydmFsbGlzIiwiY291bnRyeSI6eyJjb2RlIjoiVVMiLCJuYW1lIjoiVW5pdGVkIFN0YXRlcyJ9LCJzdWJkaXZpc2lvbiI6eyJjb2RlIjoiT1IiLCJuYW1lIjoiT3JlZ29uIn0sInRpbWV6b25lIjoiQW1lcmljYS9Mb3NfQW5nZWxlcyIsImxhdGl0dWRlIjo0NC41OTI4LCJsb25naXR1ZGUiOi0xMjMuMjc0Nn0=’,
‘x-nf-request-id’: ‘01J1QRMNXEYZGXC9F2G4377KXB’,
‘x-nf-site-id’: ‘fb79a99c-2ed2-4f6b-839f-bf41b9b0b12c’
},
multiValueHeaders: {
Accept: [
‘text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,/;q=0.8,application/signed-exchange;v=b3;q=0.7’
],
‘Accept-Encoding’: [ ‘br’ ],
‘Accept-Language’: [ ‘en-US,en;q=0.9’ ],
‘Cache-Control’: [ ‘max-age=0’ ],
‘Cdn-Loop’: [ ‘netlify’ ],
Dnt: [ ‘1’ ],
Priority: [ ‘u=0, i’ ],
‘Sec-Ch-Ua’: [
‘“Not/A)Brand”;v=“8”, “Chromium”;v=“126”, “Google Chrome”;v=“126”’
],
‘Sec-Ch-Ua-Mobile’: [ ‘?0’ ],
‘Sec-Ch-Ua-Platform’: [ ‘“Windows”’ ],
‘Sec-Fetch-Dest’: [ ‘document’ ],
‘Sec-Fetch-Mode’: [ ‘navigate’ ],
‘Sec-Fetch-Site’: [ ‘none’ ],
‘Sec-Fetch-User’: [ ‘?1’ ],
‘Upgrade-Insecure-Requests’: [ ‘1’ ],
‘User-Agent’: [
‘Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36’
],
‘X-Country’: [ ‘US’ ],
‘X-Forwarded-For’: [ ‘2601:1c0:847e:6b50:bcb3:1655:9ba3:62cc’ ],
‘X-Forwarded-Proto’: [ ‘https’ ],
‘X-Language’: [ ‘en-US’ ],
‘X-Nf-Account-Id’: [ ‘667d92ffca7a2b26fa962351’ ],
‘X-Nf-Client-Connection-Ip’: [ ‘2601:1c0:847e:6b50:bcb3:1655:9ba3:62cc’ ],
‘X-Nf-Deploy-Id’: [ ‘6682f384a469ba6fd3ab61f9’ ],
‘X-Nf-Geo’: [
‘eyJjaXR5IjoiQ29ydmFsbGlzIiwiY291bnRyeSI6eyJjb2RlIjoiVVMiLCJuYW1lIjoiVW5pdGVkIFN0YXRlcyJ9LCJzdWJkaXZpc2lvbiI6eyJjb2RlIjoiT1IiLCJuYW1lIjoiT3JlZ29uIn0sInRpbWV6b25lIjoiQW1lcmljYS9Mb3NfQW5nZWxlcyIsImxhdGl0dWRlIjo0NC41OTI4LCJsb25naXR1ZGUiOi0xMjMuMjc0Nn0=’
],
‘X-Nf-Request-Id’: [ ‘01J1QRMNXEYZGXC9F2G4377KXB’ ],
‘X-Nf-Site-Id’: [ ‘fb79a99c-2ed2-4f6b-839f-bf41b9b0b12c’ ],
host: [ ‘subtle-crepe-f83d81.netlify.app’ ]
},
queryStringParameters: {},
multiValueQueryStringParameters: {},
body: ‘’,
isBase64Encoded: true,
blobs: ‘eyJwcmltYXJ5X3JlZ2lvbiI6InVzLWVhc3QtMiIsInVybCI6Imh0dHBzOi8vZWRnZS5uZXRsaWZ5YmxvYnMuY29tIiwidXJsX3VuY2FjaGVkIjoiaHR0cHM6Ly9lZGdlLXVuY2FjaGVkLm5ldGxpZnlibG9icy5jb20iLCJ0b2tlbiI6ImV5SmhiR2NpT2lKSVV6STFOaUlzSW5SNWNDSTZJa3BYVkNKOS5leUpwYzNNaU9pSnVaWFJzYVdaNUlpd2ljM1ZpSWpvaU1DSXNJbVY0Y0NJNk1UY3hPVGcxT1RFMU5Td2lhV0YwSWpveE56RTVPRFU0TWpVMUxDSnphWFJsWDJsa0lqb2labUkzT1dFNU9XTXRNbVZrTWkwMFpqWmlMVGd6T1dZdFltWTBNV0k1WWpCaU1USmpJbjAuT3R4Q1FuVWV6UlpMbnFLZjJOX19ad3RNTGQ3V18tSEc4X1RYTkFNUFdhVSJ9’,
flags: {
serverless_functions_fix_empty_body: true,
serverless_functions_next_otel: false,
serverless_functions_nextjs_durable_cache: false,
serverless_functions_request_interceptor: false,
serverless_functions_request_interceptor_v2: true,
serverless_functions_test_flag: true,
serverless_functions_wait_event_loop: true
},
invocationMetadata: { accountTier: ‘Starter’ }
}Jul 1, 11:24:15 AM: f8e56cc6 ERROR Missing siteID or token in environment variables
my function:require(‘dotenv’).config();
const { getStore } = require(‘@netlify/blobs’);
exports.handler = function(event, context, callback) {
console.log(‘Event:’, event);
// Fetch environment variables
const siteID = process.env.NETLIFY_SITE_ID;
const token = process.env.NETLIFY_API_TOKEN;
// Ensure environment variables are set
if (!siteID || !token) {
console.error(‘Missing siteID or token in environment variables’);
return callback(null, {
statusCode: 500,
body: JSON.stringify({ error: ‘Missing siteID or token in environment variables’ })
});
}
// Get the construction store and set a value
var construction = getStore(‘clouds-001’, { siteID: siteID, token: token });
construction.set(‘file3.txt’, ‘For general carpentry’)
.then(function() {
callback(null, {
statusCode: 200,
body: ‘Nail blobs set for Construction and Beauty stores’
});
})
.catch(function(error) {
console.error(‘Error setting blobs:’, error);
callback(null, {
statusCode: 500,
body: JSON.stringify({ error: error.message })
});
});
};