我正在搜索文档,它只提供了 v3 凭证的伪代码(例如const client = new S3Client(clientParams)
如何使用存储桶和凭据初始化 S3Client 以执行 getSignedUrl 请求?任何为我指明正确方向的资源都会非常有帮助。我什至搜索了 YouTube、SO 等,但找不到有关 v3 的任何具体信息。即使文档和示例也没有提供使用凭据的实际代码。谢谢!
顺便说一句,我是否必须在文件名中包含假文件夹结构,或者我可以只使用实际的文件名吗?例如:bucket/folder1/folder2/uniqueFilename.zip 或 uniqueFilename.zip
这是我到目前为止的代码:(请记住,我正在返回以wasabiObjKey确保我获得正确的文件名。我是。我遇到问题的是客户端、GetObjectCommand 和 getSignedUrl。
exports.getPresignedUrl = functions.https.onCall(async (data, ctx) => {
const wasabiObjKey = `${data.bucket_prefix ? `${data.bucket_prefix}/` : ''}${data.uid.replace(/-/g, '_').toLowerCase()}${data.variation ? `_${data.variation.replace(/\./g, '').toLowerCase()}` : ''}.zip`
const { S3Client, GetObjectCommand } = require('@aws-sdk/client-s3')
const s3 = new S3Client({
bucketEndpoint: functions.config().s3_bucket.name,
region: functions.config().s3_bucket.region,
credentials: {
secretAccessKey: functions.config().s3.secret,
accessKeyId: functions.config().s3.access_key
}
})
const command = new GetObjectCommand({
Bucket: functions.config().s3_bucket.name,
Key: wasabiObjKey,
}) …Run Code Online (Sandbox Code Playgroud) 我必须为 android 重建我的 gradle,现在我遇到了 RNScreens 错误。
\nFailed to find fragment for React Root View在应用程序中显示。
这是日志猫:
\n2022-08-20 22:54:02.259 9195-9241/com.testApp.testApp E/WM-WorkerWrapper: Work [ id=b68c8532-e3ae-455d-9d84-a0a859f26e40, tags={ FOCUS_LOST_WORKER_TAG, com.onesignal.OSFocusHandler$OnLostFocusWorker } ] failed because it threw an exception/error\n java.util.concurrent.ExecutionException: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference\n at androidx.work.impl.utils.futures.AbstractFuture.getDoneValue(AbstractFuture.java:516)\n at androidx.work.impl.utils.futures.AbstractFuture.get(AbstractFuture.java:475)\n at androidx.work.impl.WorkerWrapper$2.run(WorkerWrapper.java:311)\n at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)\n at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)\n at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)\n at java.lang.Thread.run(Thread.java:919)\n Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.pm.PackageManager android.content.Context.getPackageManager()' on a null object reference\n …Run Code Online (Sandbox Code Playgroud) 我不确定问题是什么,因为我已经做了很多次了,没有任何问题,所以我想我搞砸了。我将展示 Product.js 组件和模块文件,如果还缺少其他内容,请告诉我(例如,也没有 next.config.js 文件)。
提前致谢!
产品.js
import { Card } from '@material-ui/core'
import styles from '../styles/Products.module.scss'
export default function Product({ product }) {
console.log(product)
return(
<Card className="product">
<img src={product.main_image} />
{product.name && product.name}
</Card>
)
}
Run Code Online (Sandbox Code Playgroud)
产品.module.scss 文件
.product {
max-width: 300px;
& img {
width: 100%;
}
}
Run Code Online (Sandbox Code Playgroud) 我搜索了文档,我似乎无法弄清楚为什么如果您刷新 firebase 托管上的工作页面,它会抛出 404。除非您尝试直接访问页面,或者如果您刷新页面(我的猜测是客户端浏览器状态和服务器状态之间存在差异)。有任何想法吗?
我有一个 SvelteKit 项目,由于某种原因,./$types没有 PageLoad 模块(其他项目也有。我不确定我做了/没有做什么才没有它。这是我收到的错误:
Module '"./$types"' has no exported member 'PageLoad'.ts(2305)
Run Code Online (Sandbox Code Playgroud)
这就是我使用它的方式(用于测试):
import { error } from '@sveltejs/kit';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ params, fetch }) => {
console.log('props from +page.ts: ', params.db_item)
// We fetch the post here using a Worker/Lambda
return params.db_item
}
Run Code Online (Sandbox Code Playgroud)
这是我的 package.json 文件:
{
"name": "test",
"version": "0.0.1",
"private": true,
"scripts": {
"dev": "vite dev",
"build": "vite build",
"preview": "vite preview",
"test": "playwright …Run Code Online (Sandbox Code Playgroud) 我有一些在本地测试的 firebase 函数,但我真的不想依赖记住切换标志或显式设置值。我可以在 firebase 中检查一个值来判断它是在 dev 还是 prod 中吗?我也在使用 NextJS,所以我也不介意在下边更改它。无论哪种方式在 firebase 生态系统中最有意义。谢谢!
在我的函数内调用客户端(在 firebase 上):
const env = new checkoutNodeSDK.core.SandboxEnvironment(clientId, clientSecret)
Run Code Online (Sandbox Code Playgroud)
我的 firebase.js 文件:
import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'
import 'firebase/functions'
const dev = true
export const app = !firebase.apps.length ? firebase.initializeApp({
apiKey: "REDACTED",
authDomain: "edit-elements.firebaseapp.com",
databaseURL: "https://edit-elements-default-rtdb.firebaseio.com",
projectId: "edit-elements",
storageBucket: "edit-elements.appspot.com",
messagingSenderId: "340652433701",
appId: "1:340652433701:web:a26472592c1538bbac7acc",
measurementId: "G-945XC7348K"
}) : firebase.app()
const auth = app.auth()
const db = app.firestore()
const functions = app.functions()
if (process.env.NODE_ENV === 'development') …Run Code Online (Sandbox Code Playgroud) environment-variables node.js firebase google-cloud-functions next.js
next.js ×3
reactjs ×2
amazon-s3 ×1
aws-sdk-js ×1
css-modules ×1
firebase ×1
node.js ×1
react-native ×1
sass ×1
svelte ×1
sveltekit ×1
typescript ×1
vite ×1