小编McL*_*vin的帖子

Spring - 如何将大型多部分文件上传到数据库而不存储在本地文件系统上

Spring引导的默认MultiPartResolver接口通过将多部分文件存储在本地文件系统上来处理它们的上载.在输入控制器方法之前,整个多部分文件必须完成上传到服务器.

我们将所有上传的文件直接存储到数据库中,我们的服务器的磁盘配额非常小,所以如果上传大文件,我们会看到IOExeption - Disk quota exceeded.

有没有办法在Spring的MultiPartResolver将文件存储在本地文件系统之前直接从客户端的传入请求获取流,以便我们可以直接流式传输到我们的数据库?

spring multipartform-data spring-mvc spring-boot

16
推荐指数
2
解决办法
1万
查看次数

AWS Elastic Beanstalk-在环境之间切换环境变量

我正在使用Elastic Beanstalk的aws:elasticbeanstalk:application:environment名称空间使用env vars配置我的环境。如何为不同的环境(例如开发与生产)设置不同的值。

发展:

option_settings:
  aws:elasticbeanstalk:application:environment:
    REDIS_HOST: localhost
Run Code Online (Sandbox Code Playgroud)

生产:

option_settings:
  aws:elasticbeanstalk:application:environment:
    REDIS_HOST: prod.redis.server.com
Run Code Online (Sandbox Code Playgroud)

amazon-ec2 amazon-web-services node.js amazon-elastic-beanstalk

6
推荐指数
1
解决办法
573
查看次数

在密钥库中扩展trustedCertEntry的到期日期

使用keytool,我试图在我拥有的密钥库中扩展trustedCertEntry的到期日期.密钥库具有以下内容

$ keytool -list -keystore certs/authTruststore.jks
Enter keystore password:

Keystore type: JKS
Keystore provider: SUN

Your keystore contains 3 entries

sts, Nov 11, 2013, trustedCertEntry,
Certificate fingerprint (SHA1): 8D:33:B7:69:DE:75:8F:22:E2:95:2C:EB:93:65:41:31:42:A6:E3:A7
__
localhost, Nov 11, 2013, PrivateKeyEntry,
Certificate fingerprint (SHA1): F4:A9:84:1E:7F:BF:5D:71:58:74:E4:C6:00:49:37:49:38:3E:31:BE
__    
security_localhost, Nov 11, 2013, trustedCertEntry,
Certificate fingerprint (SHA1): 6B:F8:E1:36:EB:36:D4:A5:6E:A0:5C:7A:E4:B9:A4:5B:63:BF:97:5D
Run Code Online (Sandbox Code Playgroud)

我可以成功修改第二个条目的过期日期,类型为PrivateKeyEntry的localhost但是当尝试使用相同的命令修改其他两个的过期时,我收到以下错误:

$ keytool -selfcert -v -alias security_localhost -validity 3650 -keystore certs/authTruststore.jks -storepass ****

keytool error: java.lang.Exception: Alias <localhost> has no key
java.lang.Exception: Alias <localhost> has no key
    at sun.security.tools.KeyTool.recoverKey(KeyTool.java:3095)
    at sun.security.tools.KeyTool.doSelfCert(KeyTool.java:2442) …
Run Code Online (Sandbox Code Playgroud)

java certificate keystore truststore private-key

5
推荐指数
1
解决办法
1万
查看次数

Socket.io 客户端在突然断开连接后无法重新连接到服务器

我正在使用 socket.io NodeJs 服务器库和 Swift 客户端库。大多数情况下,客户端在断开连接后成功重新连接到服务器,但偶尔我们会看到突然断开连接,然后客户端永远无法重新连接。

在服务器日志中,我看到客户端以定义的重试间隔发送连接尝试,但是它从未成功建立连接,然后我们得到一个ping timeout.

令人惊讶的是,对 Socket.io 的支持非常少,这使得这个问题极难解决。

node.js ios socket.io swift

5
推荐指数
1
解决办法
750
查看次数

如何使用Elastic Beanstalk自动执行EBS加密

我正在为我创建的新EC2环境加密我的根EBS卷。我知道我可以从AWS控制台和CloudFormation做到这一点,但希望能够通过Elastic Beanstalk配置文件来做到这一点。

我尝试通过在启动配置中设置EBS卷来进行操作,但是这只会从根卷中创建其他卷:

Type: AWS::AutoScaling::LaunchConfiguration
Properties:
  BlockDeviceMappings: [ DeviceName: "/dev/sdf1", Ebs: { Encrypted: true, VolumeSize: 8, VolumeType: gp2}]
Run Code Online (Sandbox Code Playgroud)

我还尝试在创建环境时创建一个新的EBS卷,但是我不确定如何动态获取EC2实例的逻辑名(我在这里使用MyEC2作为参考):

Type: AWS::EC2::Volume
Properties:
  AutoEnableIO: true
  AvailabilityZone: { "Fn::GetAtt" : [ "MyEC2", "AvailabilityZone" ] }
  Encrypted: true
  KmsKeyId: mykey
  Size: 8
  VolumeType: gp2
Run Code Online (Sandbox Code Playgroud)

从本质上讲,我需要能够使用加密的根卷创建一个新环境。任何帮助将不胜感激!

amazon-ec2 amazon-web-services aws-cloudformation amazon-elastic-beanstalk

4
推荐指数
2
解决办法
1785
查看次数

Pug 和 Parcel 不提供动态本地人

我有一个使用 Pug 模板和 Parcel 的 Express 应用程序用于我的打包器。根据 Parcel docs,我可以有一个配置文件来存储我的 locals pug.config.js,但是,我需要在运行时动态地将 locals 添加到我的模板中。是否有可能做到这一点?

这是我的文件:

索引.pug

...
h1 #{isAuthenticated}
h1 #{env}
...
Run Code Online (Sandbox Code Playgroud)

pug.config.js

module.exports = {
  locals: {
    env: process.env.NODE_ENV
  }
}
Run Code Online (Sandbox Code Playgroud)

应用程序.js

const Bundler = require('parcel-bundler')
const bundler = new Bundler(path.resolve(__dirname, 'views/index.pug'))

app
.set('views', path.join(__dirname, 'views'))
.set('view engine', 'pug')
.use(function(req, res, next) {
     res.locals.isAuthenticated = 'true'
     next()
})
.use(bundler.middleware())  
Run Code Online (Sandbox Code Playgroud)

在这里,我试图将 locals var 设置isAuthenticated'true',但是当呈现index.pug变量为空时,同时存在envpug.config.js文件中的var 。

现在,如果我尝试在我的控制器函数中呈现一个页面,res.render('index', {isAuthenticated: 'true'}) …

node.js express pug parceljs

4
推荐指数
1
解决办法
893
查看次数

IronPython - 带有自定义类的"AttributeError:object has no attribute"

这似乎只是一个我无法弄清楚的简单错误.我在C#WPF应用程序中使用IronPython,并在尝试从自定义C#类运行函数时收到以下错误:AttributeError: 'MyScriptingFunctions' object has no attribute 'Procedure'.

我正在运行的python脚本非常简单,有两行.第1行执行正常,错误发生在第2行.

    txt.Text = "some text"
    MyFunc.Procedure(5)
Run Code Online (Sandbox Code Playgroud)

MyScriptingFunctions.cs:

class MyScriptingFunctions
{
    public MyScriptingFunctions() {}

    public void Procedure(int num)
    {
        Console.WriteLine("Executing procedure " + num); 
    }
}
Run Code Online (Sandbox Code Playgroud)

以下是我设置IronPython引擎的方法:

     private void btnRunScript_Click(object sender, RoutedEventArgs e)
     {
        MyScriptingFunctions scriptFuncs = new MyScriptingFunctions();
        ScriptEngine engine = Python.CreateEngine();
        ScriptScope scope = engine.CreateScope();

        ScriptRuntime runtime = engine.Runtime;
        runtime.LoadAssembly(typeof(String).Assembly);
        runtime.LoadAssembly(typeof(Uri).Assembly);

        //Set Variable for the python script to use
        scope.SetVariable("txt", fullReadResultsTextBox);
        scope.SetVariable("MyFunc", scriptFuncs);
        string code = this.scriptTextBox.Text;
        try
        {
            ScriptSource …
Run Code Online (Sandbox Code Playgroud)

.net c# python ironpython attributeerror

3
推荐指数
1
解决办法
2292
查看次数