使用React dropzone,我已经使用onDrop回调成功访问了图像.但是,我正在尝试通过将图像发送到我的服务器,保存到S3存储桶,并将已签名的URL返回给客户端来上传到Amazon S3.
我不能用迄今为止的信息来做这件事,据我所知,文档似乎没有提到这一点.
onDrop 使用以下文件触发我的redux操作中的函数调用:
export function saveImageToS3 (files, user) {
file = files[0]
// file.name -> filename.png
// file -> the entire file object
// filepreview -> blob:http:localhost:3000/1ds3-sdfw2-23as2
return {
[CALL_API] : {
method:'post',
path: '/api/image',
successType: A.SAVE_IMAGE,
body: {
name: file.name,
file: file,
preview: file.preview,
username: user
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
但是,当我到达我的服务器时,我不确定如何保存这个blob图像(仅从浏览器中引用).
server.post('/api/image', (req, res) => {
// req.body.preview --> blob:http://localhost:3000/1ds3-sdfw2-23as2
// req.body.file -> {preview:blob:http://localhost:3000/1ds3-sdfw2-23as2}, no other properties for some reason
})
Run Code Online (Sandbox Code Playgroud) 在 Heroku 中,我的域名www.[somesite].com显示了“OK”的 ACM 状态。
我也在使用自动管理的 SSL。
在 Google Domains 上,我有一个www指向 DNS 目标的 CNAME 。
我还有一个合成记录转发@给.[somesite].comto https://www.[somesite].com,带有临时重定向,不转发路径和禁用 SSL。
如果我使用“启用 SSL”,我会收到一条错误消息:
The SSL Certificate for this domain hasn't been created yet.This process may take up to 24 hours to complete.
Run Code Online (Sandbox Code Playgroud)
但是,该站点不起作用。我不知道 Heroku 为什么会显示它,也不知道为什么它会给出 OK 的 ACM 状态。
几个小时以来,我一直在反对这一点,但不知道该怎么做。有人有想法吗?
在我的项目控制台中,我收到此消息.
目前FancyProject项目中没有应用程序
然后,我接收说明,将Firebase包含在我的应用程序的脚本标记中.
但是,我已经将它包含在我的React应用程序中,如下所示,我已经检查以确保它注册.我也可以在我的应用程序中更新我的Firebase数据库,没有任何问题.为什么这不作为应用程序添加到我的项目控制台中?
import Firebase from 'firebase'
export const config = {
apiKey: "<APIKEY>,
authDomain: "<AUTHDOMAINLINK>,
databaseURL: "<DATABASEURL>",
storageBucket: "<STORAGEBUCKET>",
messagingSenderId: "<SENDERID>"
}
let app = Firebase.initializeApp(config)
console.log(app.name) // this registers!
export const ref = Firebase.database().ref()
export const firebaseAuth = Firebase.auth
Run Code Online (Sandbox Code Playgroud) 我尝试循环遍历数组的项目,但在 TypeScript 中缺少组件的一些输入。我已经尝试过Card<any或Card<IProps>使用下面定义的接口(下面未使用)。
这是我到目前为止遇到的错误。
输入 '{ 键:数字;卡:{名称:字符串;图像:字符串;身份证号; }; }' 不可分配给类型 'IntrinsicAttributes & {children?: ReactNode; }'。属性“card”在类型“IntrinsicAttributes & {children?: ReactNode;”上不存在 }'。
我很想知道我在这里到底缺少什么?
const cards = [
{
name: "a",
image: "red",
id: 1
},
{
name: "b",
image: "blue",
id: 2
},
{
name: "c",
image: "green",
id: 3
}
];
interface IProps {
card: {
name: string;
image: string;
id: number;
};
key: string;
}
...(Stateless component logic here)...
const renderCards = () => {
return cards.map(card …Run Code Online (Sandbox Code Playgroud) /home),其中包含卡片形式的产品列表(通过\n检索useQuery),每个卡片都有一个赞成按钮/home,\nuseQuery不会\xe2\x80\x99 检索到具有正确票数的产品为什么useQuery在我刷新另一页之前\n不返回正确的金额?
作为参考,如下:
\nconst Home = props => {\n const {data, loading, error} = useQuery(GET_PRODUCTS_LOGGED_IN, {\n variables: {\n userid: props.userid\n }\n });\n \n console.log(\n 'data', data.products // this data is outdated after I go from /home -> /profile -> /home\n );\n\n return (\n <Container>\n {_.map(data.products, product => (\n <VoteButton\n hasVoted={product.hasVoted}\n likes={product.likes}\n productid={product.productid}\n />\n …Run Code Online (Sandbox Code Playgroud) reactjs ×3
amazon-s3 ×1
apollo ×1
dns ×1
firebase ×1
graphql ×1
heroku ×1
hosting ×1
javascript ×1
react-redux ×1
ssl ×1
typescript ×1