Add file to database
This commit is contained in:
parent
54e6b0a139
commit
80e3c8cc3a
3 changed files with 66 additions and 48 deletions
|
@ -4,9 +4,7 @@ use warnings;
|
||||||
use v5.26;
|
use v5.26;
|
||||||
|
|
||||||
use Carp;
|
use Carp;
|
||||||
use Data::Dumper;
|
|
||||||
use File::Find;
|
use File::Find;
|
||||||
use SQL::Abstract;
|
|
||||||
use DBI;
|
use DBI;
|
||||||
|
|
||||||
my $db =
|
my $db =
|
||||||
|
@ -14,17 +12,18 @@ my $db =
|
||||||
or confess $DBI::errstr;
|
or confess $DBI::errstr;
|
||||||
|
|
||||||
sub sqlstr {
|
sub sqlstr {
|
||||||
|
my ( $table, $primary ) = @_;
|
||||||
return qq
|
return qq
|
||||||
/create table if not exists @_ (
|
/create table if not exists $table (
|
||||||
id integer primary key autoincrement,
|
id integer / . ( $primary ? 'primary key autoincrement' : '' ) . qq/,
|
||||||
title text,
|
title text,
|
||||||
filepath text,
|
filepath text,
|
||||||
content text
|
content text
|
||||||
);/;
|
);/;
|
||||||
}
|
}
|
||||||
my %tablesql = (
|
my %tablesql = (
|
||||||
"origin" => sqlstr("origin"),
|
"origin" => sqlstr( "origin", 1 ),
|
||||||
"trans" => sqlstr("trans"),
|
"trans" => sqlstr( "trans", 0 ),
|
||||||
);
|
);
|
||||||
my $act;
|
my $act;
|
||||||
for my $table ( keys %tablesql ) {
|
for my $table ( keys %tablesql ) {
|
||||||
|
|
|
@ -8,8 +8,12 @@ use Time::Piece;
|
||||||
use Digest::SHA qw(sha256_hex hmac_sha256_hex);
|
use Digest::SHA qw(sha256_hex hmac_sha256_hex);
|
||||||
use JSON::MaybeXS qw(encode_json);
|
use JSON::MaybeXS qw(encode_json);
|
||||||
|
|
||||||
|
use Exporter 'import';
|
||||||
|
our @EXPORT_OK = 'sign';
|
||||||
|
|
||||||
|
sub sign {
|
||||||
|
my $SourceText = @_;
|
||||||
carp "You must provide SecretKey.csv to parent folder!";
|
carp "You must provide SecretKey.csv to parent folder!";
|
||||||
our $SourceText ;
|
|
||||||
my $data = {
|
my $data = {
|
||||||
SourceText => $SourceText,
|
SourceText => $SourceText,
|
||||||
Source => 'en',
|
Source => 'en',
|
||||||
|
@ -66,7 +70,8 @@ my $SecretService = hmac_sha256_hex( $SecretDate, $service );
|
||||||
my $SecretSigning = hmac_sha256_hex( $SecretService, "tc3_request" );
|
my $SecretSigning = hmac_sha256_hex( $SecretService, "tc3_request" );
|
||||||
my $Signature = hmac_sha256_hex( $SecretSigning, $StringToSign );
|
my $Signature = hmac_sha256_hex( $SecretSigning, $StringToSign );
|
||||||
|
|
||||||
our $Authorization =
|
my $Authorization =
|
||||||
"$Algorithm Credential=$SecretID/$CredentialScope, SignedHeaders=$SignedHeaders, Signature=$Signature";
|
"$Algorithm Credential=$SecretID/$CredentialScope, SignedHeaders=$SignedHeaders, Signature=$Signature";
|
||||||
|
return $Authorization;
|
||||||
|
}
|
||||||
|
|
||||||
say $payload;
|
|
14
Translator/translate.pl
Normal file
14
Translator/translate.pl
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
#!/usr/bin/perl
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use v5.26;
|
||||||
|
|
||||||
|
use Carp;
|
||||||
|
use File::Find;
|
||||||
|
use DBI;
|
||||||
|
use lib 'sign.pl';
|
||||||
|
|
||||||
|
my $db =
|
||||||
|
DBI->connect( "DBI:SQLite:dbname=../data.db", "", "", { RaiseError => 1 } )
|
||||||
|
or confess $DBI::errstr;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue