我有一个函数,在添加了一些更改后,我开始删除ERROR: duplicate connection name 函数并创建新的函数
这是我的功能
create extension dblink;
create or replace function Log_Save (Moderator integer, Subject varchar(32), ID_Subject integer, LogAction varchar(64), LogText varchar(4000))
returns void as $$
begin
perform dblink_connect('pragma','dbname=myDbName');
perform dblink_exec('pragma','insert into "Log" ("Moderator", "Subject", "ID_Subject", "Text", "Action", "LogDate") values (' ||
Moderator ||
', ''' || Subject || ''',' ||
ID_Subject ||
',''' || LogText || ''', ''' ||
LogAction || ''', ''' || now() || ''');');
perform dblink_exec('pragma','commit;');
perform dblink_disconnect('pragma');
end; $$
language plpgsql;
Run Code Online (Sandbox Code Playgroud)
我在运行时发现错误 …
我已经知道如何在数据库中存储图像,只需bytea在我的表中使用类型
我已经可以通过我的项目 .net Core 中的代码将图像保存到数据库中,我刚刚获取图像url并像那里一样保存:
using (HttpResponseMessage res = await client.GetAsync(photo_url))
using (HttpContent content = res.Content) {
byte[] imageByte = await content.ReadAsByteArrayAsync();
using (NpgsqlConnection conn = new NpgsqlConnection("ConnectionString")) {
conn.Open();
using (NpgsqlTransaction tran = conn.BeginTransaction())
using (NpgsqlCommand cmd = new NpgsqlCommand("Photo_Save", conn)) {
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("photo", NpgsqlTypes.NpgsqlDbType.Bytea, imageByte);
cmd.ExecuteScalar();
tran.Commit();
}
}
Run Code Online (Sandbox Code Playgroud)
它运作良好
但我需要从我的电脑保存到表格图像
有没有什么方法可以在没有主机或任何其他项目的代码的情况下将图像上传到数据库中,只需使用本地图片并连接到Postges DB?
我有一个与 Nginx 重定向相关的问题,您可以在下面看到配置。我的目标是从https://example.com重定向到https://www.example.com
我几乎在stackoverflow中查看了所有内容,但没有找到任何帮助。请帮我解决这个问题。我将提供有关我的 Nginx Web 服务器的所有必要信息。我希望你能帮我解决这个难题。
我的文件nginx.conf看起来像那里:
user www-data;
worker_processes 4;
pid /run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
server_names_hash_bucket_size 64;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_static on;
gzip_disable "msie6";
gzip_vary on;
gzip_proxied any;
gzip_comp_level 9;
# gzip_buffers 16 8k;
gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xm$
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
Run Code Online (Sandbox Code Playgroud)
我的档案 /etc/nginx/sites-enabled/example:
server { …Run Code Online (Sandbox Code Playgroud) 作为初级开发人员,我应该找到一个使用ftp下载文件的解决方案,我有这个代码.
它工作但有时,我无法打开下载的文件.
public static bool DownloadDocument(string ftpPath, string downloadPath) {
bool retVal = false;
try {
Uri serverUri = new Uri(ftpPath);
if (serverUri.Scheme != Uri.UriSchemeFtp) {
return false;
}
FtpWebRequest reqFTP;
reqFTP = (FtpWebRequest)FtpWebRequest.Create(ftpPath);
reqFTP.Credentials = new NetworkCredential(Tools.FtpUserName, Tools.FtpPassword);
reqFTP.KeepAlive = false;
reqFTP.Method = WebRequestMethods.Ftp.DownloadFile;
reqFTP.UseBinary = true;
reqFTP.Proxy = null;
reqFTP.UsePassive = false;
using (FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse()) {
using (Stream responseStream = response.GetResponseStream()) {
using (FileStream writeStream = new FileStream(downloadPath, FileMode.Create)) {
int Length = 1024 * 1024 …Run Code Online (Sandbox Code Playgroud) 我有一个Response带泛型参数的类:
public class Response<T> where T : class {
public bool Result;
public T Data;
}
Run Code Online (Sandbox Code Playgroud)
另外,我有一个Instance简单参数的类
public sealed class Instance {
public long Rank { get; set; }
public int ID_Member { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
然后我有一个课程,我使用最后一个
public sealed class InstanceResponse : Response<IList<Instance>> { }
Run Code Online (Sandbox Code Playgroud)
我尝试在最后一堂课中添加一个构造函数,但不明白该怎么做
我尝试过那样,但它不起作用,JsonString包含序列化类InstanceResponse
public sealed class InstanceResponse : Response<IList<Instance>> {
public InstanceResponse(string JsonString) {
this = JsonConvert.DeserializeObject<InstanceResponse>(JsonString);
}
}
Run Code Online (Sandbox Code Playgroud)
我有一个错误 Cannot assign to 'this' because it is read-only
怎么可能?
对于加密、解密、签名和验证签名,我使用此处的代码DotnetCore.RSA
在我开始处理大文本之前,它一直运行良好。
通过 RSA 加密不适用于大文本。大,超过 245 个字节,具有 2048 个 RSA 密钥
我在尝试加密大文本时遇到异常:
异常消息:Interop.Crypto.OpenSslCryptographicException: 'error:0406D06E:rsa routines:RSA_padding_add_PKCS1_type_2:data too large for key size'
加密功能:
public string Encrypt(string text) {
if (_publicKeyRsaProvider == null) {
throw new Exception("_publicKeyRsaProvider is null");
}
return Convert.ToBase64String(_publicKeyRsaProvider.Encrypt(Encoding.UTF8.GetBytes(text), RSAEncryptionPadding.Pkcs1));
}
Run Code Online (Sandbox Code Playgroud)
编写 DotnetCore.RSA 的开发人员建议将长文本分成许多小文本,分别加密并连接它们
有什么建议吗,正常还是不正常?也许建议一些用于 .net Core 的 RSA 加密库
我试图获取 _id 插入的对象:
let id;
db.collection("collection-name")
.insertOne(document)
.then(result => {
id = result.insertedId;
console.log(result.insertedId);
})
.catch(err => {
});
console.log("id", id);
Run Code Online (Sandbox Code Playgroud)
在控制台中我看到了insertedId但如何将其导出到外面then
在控制台后insertOne我看到id undefind
c# ×3
.net-core ×2
postgresql ×2
bytea ×1
dblink ×1
encryption ×1
ftp ×1
generics ×1
javascript ×1
mongodb ×1
nginx ×1
node.js ×1
rsa ×1
winginx ×1