我在 AWS 上有一个 S3 存储桶,我正在将图像从前端上传到其中。
成功将图像上传到 S3 后,这是我得到的 URL -
https://cewa-foundation-2020.s3.amazonaws.com/image8_%281%29.webp-1628768330444.webp
我想公开此 URL,以便任何知道此链接的人都可以查看该图像。
我怎样才能实现这个目标?
我想在 Node 应用程序中使用 Stripe Prebuilt Checkout Page 构建一个简单的结账页面。
我遵循了 Stripe 文档中的所有必要步骤,但 API 请求似乎不起作用。
server.js -
const express = require("express");
const stripe = require("stripe")(
"<mySecretKey>"
);
const app = express();
app.get("/checkout-sucess", (req, res) => {
res.send("<h1>Success</h1>");
});
app.get("/checkout-cancel", (req, res) => {
res.send("<h1>Cancelled</h1>");
});
app.post("/create-checkout-session", async (req, res) => {
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
line_items: [
{
price_data: {
currency: "inr",
product_data: {
name: "Cewa",
},
unit_amount: 200,
},
quantity: 1,
},
],
mode: "payment",
success_url: "/checkout-success",
cancel_url: …Run Code Online (Sandbox Code Playgroud) 我有一个 Nestjs 和 MongoDB 应用程序。
auth.module.ts-
@Module({
imports: [
MongooseModule.forFeature([{ name: User.name, schema: UserSchema }]),
],
controllers: [AuthController],
providers: [AuthService],
})
export class AuthModule {}
Run Code Online (Sandbox Code Playgroud)
auth.service.ts-
@Injectable()
export class AuthService {
// Inject User model into AuthService
constructor(@InjectModel(User.name) private userModel: Model<UserDocument>) {}
getUser(username: string) {
const user = this.userModel.find({ name: username });
return user;
}
}
Run Code Online (Sandbox Code Playgroud)
@nestjs/mongoose我使用和创建了一个 UserSchema mongoose。
根据文档,当我导入MongooseModule模块中使用的架构时,该架构只能在该特定模块中使用。
如果我想访问我的模块和服务中的多个模型怎么办?有办法吗?
如何将多个模型注入到服务中?
I am trying to upload a file from Node.js application to AWS S3 Bucket.
async uploadFile(file: any) {
try {
console.log(file);
const s3Params = {
Bucket: xyz,
Key: String(file.originalname),
Body: file.buffer,
};
await s3.upload(s3Params, (err, data) => {
if (err) return console.log({ err });
else console.log({ data });
});
} catch (error) {
return { data: null, error, status: 500 };
}
}
}
Run Code Online (Sandbox Code Playgroud)
Say, if I have a folder inside bucket xyz called /images, where do I specify …