Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xpub-epmc
Manage
Activity
Members
Labels
Plan
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Literature-services
public-projects
xpub-epmc
Commits
a336c8e9
Commit
a336c8e9
authored
6 years ago
by
Yogmatee Roochun
Browse files
Options
Downloads
Patches
Plain Diff
xsweet conversion - ftp
parent
13dcdd67
No related branches found
No related tags found
2 merge requests
!93
Shared data model
,
!94
Dev
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
server/xsweet-conversion/index.js
+14
-10
14 additions, 10 deletions
server/xsweet-conversion/index.js
yarn.lock
+254
-235
254 additions, 235 deletions
yarn.lock
with
268 additions
and
245 deletions
server/xsweet-conversion/index.js
+
14
−
10
View file @
a336c8e9
const
fs
=
require
(
'
fs
'
)
const
request
=
require
(
'
request
'
)
const
rp
=
require
(
'
request-promise
'
)
const
tar
=
require
(
'
../utils/unTar.js
'
)
const
logger
=
require
(
'
@pubsweet/logger
'
)
...
...
@@ -10,14 +9,14 @@ const path = require('path')
const
files
=
require
(
'
../utils/files.js
'
)
const
db
=
require
(
'
../utils/db.js
'
)
// '/home/yogmatee/projects/xmlValidation_files/xweet_files/tiana.docx'
/*
xsweetConvert(
'/home/yogmatee/projects/xmlValidation_files/xweet_files/tiana.docx',
'
EMS9000
2
'
,
'EMS9000
5
',
)
*/
function
xsweetConvert
(
fileUrl
,
manuscriptId
)
{
module
.
exports
.
xsweetConvert
=
function
xsweetConvert
(
fileUrl
,
manuscriptId
)
{
const
options
=
{
method
:
'
POST
'
,
uri
:
'
http://localhost:3000/convertDocxToHTML
'
,
...
...
@@ -33,18 +32,19 @@ function xsweetConvert(fileUrl, manuscriptId) {
}
rp
(
options
)
.
then
(
async
function
(
body
)
{
.
then
(
async
body
=>
{
try
{
const
tmpPath
=
await
tar
.
createTempDir
()
const
user
=
await
getUser
.
getAdminUser
()
fs
.
writeFileSync
(
`
${
tmpPath
}
/
${
manuscriptId
}
.html`
,
body
)
console
.
log
(
'
The file has been saved!
'
,
tmpPath
)
const
fileInfo
=
getFileInfo
(
`
${
tmpPath
}
/
${
manuscriptId
}
.html`
,
manuscriptId
,
user
,
)
const
uuid
=
uuidv4
()
// upload to minio
files
.
uploadFileToMinio
(
`
${
uuid
}${
fileInfo
.
extension
}
`
,
...
...
@@ -52,14 +52,18 @@ function xsweetConvert(fileUrl, manuscriptId) {
fileInfo
.
url
,
fileInfo
.
mimeType
,
)
// update object details for database upsert
fileInfo
.
url
=
`/download/
${
uuid
}${
fileInfo
.
extension
}
`
delete
fileInfo
.
extension
await
db
.
upsertHtmlPrevFile
(
fileInfo
)
console
.
log
(
'
file has been uploaded to Minio and to db
'
)
await
db
.
upsertHtmlPrevFile
(
fileInfo
,
manuscriptId
)
logger
.
info
(
'
file has been uploaded to Minio and to db
'
)
}
catch
(
err
)
{
throw
err
}
})
.
catch
(
function
(
err
)
{
.
catch
(
err
=>
{
logger
.
error
(
'
Conversion failed:
'
,
err
)
})
}
...
...
This diff is collapsed.
Click to expand it.
yarn.lock
+
254
−
235
View file @
a336c8e9
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment