如何为弹性 beanstalk Windows 应用程序设置文件夹权限? [英] How can I set folder permissions for elastic beanstalk windows application?
问题描述
我目前正在构建一个 C# WebApi 2 应用程序,我将上传到 Amazon Elastic Beanstalk 实例进行部署.到目前为止我已经成功了,在我的本地机器上,我刚刚完成了文件上传功能的测试,以便客户端上传图片.
I am currently building a C# WebApi 2 application that I will be uploading to an Amazon Elastic Beanstalk instance to deploy. I am having success so far, and on my local machine, I just finished testing the file upload capability in order for clients to upload images.
它的方式是我接受 Web Api 中的 multipart/formdata 并将临时文件(使用随机名称,如 BodyPart_24e246c7-a92a-4a3d-84ef-c1651416e667)保存到 App_Data 文件夹.临时文件被放入一个 S3 存储桶中,我在我的 SQL Server 数据库中创建了一个对它的引用.
The way it goes is I accept the multipart/formdata in the Web Api and save the temp file (with a random name like BodyPart_24e246c7-a92a-4a3d-84ef-c1651416e667) to the App_Data folder. The temporary file is put into an S3 Bucket and I create a reference in my SQL Server database to it.
在本地上传单个或多个文件时测试工作正常,但是当我将应用程序部署到 Elastic Beanstalk 并尝试上传时,我收到类似 找不到路径的一部分 'C:inetpubwwwrootsbeAPI_deployApp_DataBodyPart_8f552d48-ed9b-4ec2-9986-88cbffd673ee'" 或类似的人说访问被完全拒绝.
Testing works fine with single or multiple file uploads locally but when I deploy the application to Elastic Beanstalk and try to upload I get errors like "Could not find a part of the path 'C:inetpubwwwrootsbeAPI_deployApp_DataBodyPart_8f552d48-ed9b-4ec2-9986-88cbffd673ee'" or a similar one saying access is denied altogether.
几个小时以来,我一直试图在网上找到解决方案,但 AWS 文档到处都是,教程/其他问题似乎已经过时.我认为这与没有权限在 EC2 服务器上写入临时文件有关,但我不知道如何解决.
I have been trying to find the solution online for a few hours now, but the AWS documentation is all over the place and tutorials/other questions seem to be outdated. I believe it has something to do with not having permission to write the temporary files on the EC2 server, but I can't figure out how to fix it.
非常感谢.
推荐答案
这在 2013 年 4 月已经成为可能,另见 此处:基本上您需要执行的步骤如下:
This is already possible since April 2013, see also here: Basically the steps you need to perform are the following:
- 通过解决方案资源管理器在项目的顶层创建一个名为 .ebextensions 的文件夹
- 在此文件夹中添加您的配置文件,例如 myapp.config(将 myapp 替换为您的 Elastic Beanstalk 的应用程序名称)
- 将下面显示的代码添加到您刚刚创建的配置文件中.将
MyApp
替换为您在 Visual Studio 中显示的项目名称(不是解决方案名称) 一切就绪!!确保 App_Data 中有一个文件,否则 Visual Studio 不会发布它.
- Create a folder called .ebextensions in the top-level of your project through the solution explorer
- Add in this folder your configuration file e.g myapp.config (replace myapp with your Elastic Beanstalk's app name)
- Add the code displayed underneath to this configuration file you just created. Replace
MyApp
with your project name (not solution name) displayed in Visual Studio All set!! Be sure there's a file within App_Data otherwise Visual Studio won't publish it.
{
"containercommands": {
"01-changeperm": {
"command": "icacls "C:/inetpub/wwwroot/MyApp_deploy/App_Data" /grant DefaultAppPool:(OI)(CI)"
}
}
}
这篇关于如何为弹性 beanstalk Windows 应用程序设置文件夹权限?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!