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
a5e471e9
Commit
a5e471e9
authored
6 years ago
by
Yogmatee Roochun
Browse files
Options
Downloads
Patches
Plain Diff
modified something
parent
ce9968b8
No related branches found
No related tags found
2 merge requests
!98
Dev
,
!97
Shared data model
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
server/xsweet-conversion/index.js
+29
-32
29 additions, 32 deletions
server/xsweet-conversion/index.js
with
29 additions
and
32 deletions
server/xsweet-conversion/index.js
+
29
−
32
View file @
a5e471e9
...
...
@@ -12,15 +12,17 @@ const db = require('../utils/db.js')
const
pubsweetServer
=
config
.
get
(
'
pubsweet-server.baseUrl
'
)
const
label
=
'
xsweet conversion
'
/*
xsweetConvert(
'/home/yogmatee/projects/xmlValidation_files/xweet_files/tiana.docx',
'EMS9000
8
',
'EMS9000
5
',
)
*/
module
.
exports
.
xsweetConvert
=
function
xsweetConvert
(
fileUrl
,
manuscriptId
)
{
module
.
exports
.
xsweetConvert
=
async
function
xsweetConvert
(
fileUrl
,
manuscriptId
,
)
{
const
options
=
{
method
:
'
POST
'
,
uri
:
`
${
pubsweetServer
}
/convertDocxToHTML`
,
...
...
@@ -33,40 +35,35 @@ module.exports.xsweetConvert = function xsweetConvert(fileUrl, manuscriptId) {
},
}
rp
(
options
)
.
then
(
body
=>
{
await
rp
(
options
)
.
then
(
async
body
=>
{
try
{
return
new
Promise
(
async
resolve
=>
{
const
tmpPath
=
await
tar
.
createTempDir
()
const
user
=
await
getUser
.
getAdminUser
()
fs
.
writeFileSync
(
`
${
tmpPath
}
/
${
manuscriptId
}
.html`
,
body
)
const
tmpPath
=
await
tar
.
createTempDir
()
const
user
=
await
getUser
.
getAdminUser
()
fs
.
writeFileSync
(
`
${
tmpPath
}
/
${
manuscriptId
}
.html`
,
body
)
const
fileInfo
=
getFileInfo
(
`
${
tmpPath
}
/
${
manuscriptId
}
.html`
,
manuscriptId
,
user
,
label
,
)
const
uuid
=
uuidv4
()
const
fileInfo
=
getFileInfo
(
`
${
tmpPath
}
/
${
manuscriptId
}
.html`
,
manuscriptId
,
user
,
label
,
)
const
uuid
=
uuidv4
()
// upload to minio
files
.
uploadFileToMinio
(
`
${
uuid
}${
fileInfo
.
extension
}
`
,
fileInfo
.
filename
,
fileInfo
.
url
,
fileInfo
.
mimeType
,
)
// upload to minio
files
.
uploadFileToMinio
(
`
${
uuid
}${
fileInfo
.
extension
}
`
,
fileInfo
.
filename
,
fileInfo
.
url
,
fileInfo
.
mimeType
,
)
// update object details for database upsert
fileInfo
.
url
=
`/download/
${
uuid
}${
fileInfo
.
extension
}
`
delete
fileInfo
.
extension
// update object details for database upsert
fileInfo
.
url
=
`/download/
${
uuid
}${
fileInfo
.
extension
}
`
delete
fileInfo
.
extension
await
db
.
upsertHtmlPrevFile
(
fileInfo
,
manuscriptId
)
logger
.
info
(
'
HTML converted file has been uploaded to Minio and to db
'
,
)
resolve
(
true
)
})
await
db
.
upsertHtmlPrevFile
(
fileInfo
,
manuscriptId
)
logger
.
info
(
'
HTML converted file has been uploaded to Minio and to db
'
)
}
catch
(
err
)
{
throw
err
}
...
...
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