我必须使用JavaScript创建表单,用户将上传JPG文件并提交其他信息,如姓名,电子邮件等.当用户单击提交时,表单中的所有信息都将加载到值对象.对于我设置的图像文件byte[].
所以假设:
public String name;
public String email;
public byte[] logo;
Run Code Online (Sandbox Code Playgroud)
我也设置了一个servlet来处理提交,但我不知道如何开始.上传如何工作?用户提交时,如何获取图像信息?这是一个截图:http://imageshack.us/f/32/77675354.png/我需要转换该图像并将其保存为byte[]然后转换为blob,以便我可以将其插入表中.
有没有一种方法可以像创建分支的树结构一样显示?
假设我从MASTER开始然后到SONAR-VIOLATIONS再到PROJECT_ONE_VIOLATION,那么显示新分支从何处分支的命令/方法是什么?在某种树形结构?
所以在我的jrxml文件中,我有以下内容:
<parameter name="smileyfaceimage" class="java.lang.String"/>
Run Code Online (Sandbox Code Playgroud)
然后我参考:
<image scaleImage="FillFrame" onErrorType="Blank">
<reportElement x="167" y="62" width="363" height="171" backcolor="#333333"/>
<imageExpression class="java.lang.String"><![CDATA[$P{smileyfaceimage}]]></imageExpression>
</image>
Run Code Online (Sandbox Code Playgroud)
这不正确吗?
无论有没有,我都尝试过base64:
data:image/png;base64,
Run Code Online (Sandbox Code Playgroud)
这是我正在使用的图像
然后我使用https://www.base64-image.de/或任何随机网站来获取base64字符串.我测试了它产生的字符串,它是有效的.
现在在我的代码中;
<parameter name="smileyfaceimage" class="java.lang.String"/>然后将图像数据添加到页面:
<image scaleImage="FillFrame" onErrorType="Blank">
<reportElement x="167" y="62" width="363" height="171" backcolor="#333333"/>
<imageExpression><![CDATA[new java.io.ByteArrayInputStream(org.apache.commons.codec.binary.Base64.decodeBase64($P{smileyfaceimage}.getBytes()))]]></imageExpression>
</image>
Run Code Online (Sandbox Code Playgroud)我错过了一步吗?
我确定我已经将我的Lambda设置为具有对私有桶的读/写访问权限; 更具体地说,我的lambda将执行s3.headObject和s3.upload.为了让这个工作,我错过了什么?
我的Lambda的政策:
{
"Statement": [
{
"Resource": "arn:aws:logs:us-east-1:*:*",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Effect": "Allow"
},
{
"Resource": "arn:aws:s3:::PRIVATE_BUCKET/folder_name/*",
"Action": [
"s3:GetObject",
"s3:PutObject"
],
"Effect": "Allow"
}
],
"Version": "2012-10-17"
Run Code Online (Sandbox Code Playgroud)
}
我的S3存储策略:
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "Bucket that is read-accessible internally",
"Parameters" : {
"Environment" : {
"Description" : "dev",
"Type" : "String",
"Default" : "dev",
"AllowedValues" : [ "dev" ]
}
},
"Resources" : {
"PrivateBucket" : {
"Type" : "AWS::S3::Bucket", …Run Code Online (Sandbox Code Playgroud) amazon-s3 amazon-web-services aws-lambda serverless-framework
我正在尝试使用knn创建一个简单的推荐系统.
可以说我有一张桌子:
User | Book1 | Book2 | Book3 | Book4 | Book5 | Book6 | Book7 |
1 | 5 | ? | 3 | ? | 4 | 3 | 2 |
2 | 3 | 4 | ? | 2 | 3 | 4 | 2 |
3 | 4 | 2 | 1 | ? | ? | 3 | 3 |
4 | 2 | 5 | 3 | ? | 4 | 1 | …Run Code Online (Sandbox Code Playgroud) 我的应用程序向某些api服务发出http请求,该服务返回一个gzip压缩响应.如何确保响应确实是gzip格式?我很困惑为什么在提出请求后我没有解压缩它.
以下是我的代码:
public static String streamToString(InputStream stream) {
BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
StringBuilder sb = new StringBuilder();
String line;
try {
while ((line = reader.readLine()) != null) {
sb.append(line).append("\n");
}
} catch (IOException e) {
logger.error("Error while streaming to string: {}", e);
} finally {
try { stream.close(); } catch (IOException e) { }
}
return sb.toString();
}
public static String getResultFromHttpRequest(String url) throws IOException { // add retries, catch all exceptions
HttpClient httpclient = new DefaultHttpClient();
HttpGet …Run Code Online (Sandbox Code Playgroud) 所以在我的 scala 类中,我不得不使用 Jsch(JAVA) 库来做 SFTP 工作。但由于某种原因,它无法导入:
import com.jcraft.jsch.ChannelSftp.LsEntry
Run Code Online (Sandbox Code Playgroud)
知道为什么会这样吗?LsEntry 是 ChannelSftp 的嵌套类。
http://epaul.github.io/jsch-documentation/simple.javadoc/com/jcraft/jsch/ChannelSftp.html
package services.impl
import java.nio.file.Path
import com.jcraft.jsch.ChannelSftp
import com.jcraft.jsch.ChannelSftp.LsEntry
import services.InputService
class InputServiceImpl extends InputService[List[ChannelSftp.LsEntry]] {
}
Run Code Online (Sandbox Code Playgroud) 我写了一些基本的js来列出FTP的文件,但我得到:
"在完成请求之前退出流程"
那是因为Lambda无法与FTP交互吗?
我正在使用jsftp btw.
这是我的设置:
我的代码:
// Require Serverless ENV vars
var ServerlessHelpers = require('serverless-helpers-js').loadEnv();
// Require Logic
var lib = require('../lib');
// Lambda Handler
module.exports.handler = function (event, context) {
lib.respond(event, function (error, response) {
return context.done(error, response);
});
};
Run Code Online (Sandbox Code Playgroud)
我的ftp lambda代码:
var JSFtp = require("jsftp");
module.exports.respond = function (event, cb) {
var ftp = new JSFtp({
host: "host",
user: "user",
password: "password"
});
ftp.auth(ftp.user, ftp.password, function(err, res) {
if (err) console.log(err);
else console.log(res); …Run Code Online (Sandbox Code Playgroud) 我不知道该怎么办了.一切似乎都是正确的; 输入输出.
我生成xml文件并发送到某些服务进行验证.
回应是:
11:10:34,922 INFO [STDOUT] printing out the input stream
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><Response>
<Method name="XML/Release/New" time="2013-04-23T15:10:35.1446238Z">
<ResponseStatus>100</ResponseStatus>
</Method>
</Response>
finished printing out the input stream
11:10:34,922 INFO [STDOUT] got the unmarshaller
11:10:34,925 ERROR [PRNDataAccessUtil] Caught an error: javax.xml.bind.UnmarshalException
- with linked exception: [org.xml.sax.SAXParseException: Premature end of file.] : null
Run Code Online (Sandbox Code Playgroud)
代码:
try {
out = connection.getOutputStream();
ByteArrayOutputStream bos = PRNPostNewsReleaseUtil.createNewsReleaseXml(newsRelease);
bos.writeTo(out);
JAXBContext context = JAXBContext.newInstance(Response.class.getPackage().getName());
in = connection.getInputStream();
BufferedReader inp = new BufferedReader(new InputStreamReader(in));
System.out.println("printing out the input …Run Code Online (Sandbox Code Playgroud)