Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
web-ui
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
WEBGDE-Components
web-ui
Commits
1c5c893e
Commit
1c5c893e
authored
Apr 28, 2023
by
Owen Ryan Ang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented file:// protocol for image fetching
parent
6aee2a9f
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
2 deletions
+54
-2
config.js
WebGde/WebContent/config.js
+5
-0
accessFile.js
WebGde/WebContent/src/accessFile/accessFile.js
+15
-0
Request.java
.../main/java/com/svi/webgde/restservice/object/Request.java
+13
-0
GDEWebServices.java
...a/com/svi/webgde/restservice/services/GDEWebServices.java
+21
-2
No files found.
WebGde/WebContent/config.js
View file @
1c5c893e
...
...
@@ -60,3 +60,8 @@ var REASON_LIST = "Reason1,Reason2,Reason3,Reason4"
//KEYCLOAK CONFIG
const
REDIRECT_URL
=
'http://auth-server/auth/realms/GFS/protocol/openid-connect/logout?redirect_uri=encodedRedirectUri'
;
//Temporary variables for dev
var
LOCAL_DOMAIN
=
"http://localhost:8080"
var
LOCAL_FETCH_URL
=
LOCAL_DOMAIN
+
"/WebGde/svc/gfs-rest/fetch-local"
var
LOCAL_FETCH_TEST_URL
=
"http://localhost:8080/Sample_API/testservice/file"
WebGde/WebContent/src/accessFile/accessFile.js
View file @
1c5c893e
...
...
@@ -114,6 +114,21 @@ async function accessFile() {
if
(
img
!=
null
?
img
.
startsWith
(
"http"
)
:
false
)
{
response
=
await
fetch
(
img
);
gfsFileName
=
getGfsFileName
(
response
.
headers
.
get
(
"content-disposition"
));
}
else
if
(
img
!=
null
?
img
.
startsWith
(
"file"
)
:
false
){
console
.
log
(
'file'
);
const
payload
=
{
dir
:
img
};
response
=
await
fetch
(
`
${
GFS_URL
}
/fetch-local`
,
{
method
:
'POST'
,
headers
:
{
'Content-Type'
:
'application/json'
},
body
:
JSON
.
stringify
(
payload
)
})
gfsFileName
=
getGfsFileName
(
response
.
headers
.
get
(
"content-disposition"
));
}
else
{
let
formData
=
new
FormData
();
formData
.
append
(
"data"
,
JSON
.
stringify
({
...
...
WebGde/src/main/java/com/svi/webgde/restservice/object/Request.java
0 → 100644
View file @
1c5c893e
package
com
.
svi
.
webgde
.
restservice
.
object
;
public
class
Request
{
private
String
dir
;
public
String
getDir
()
{
return
dir
;
}
public
void
setDir
(
String
dir
)
{
this
.
dir
=
dir
;
}
}
WebGde/src/main/java/com/svi/webgde/restservice/services/GDEWebServices.java
View file @
1c5c893e
...
...
@@ -32,6 +32,7 @@ import org.json.simple.JSONArray;
import
com.opencsv.CSVReader
;
import
com.opencsv.CSVWriter
;
import
com.svi.template.restservice.globals.AppConfig
;
import
com.svi.training.services.Request
;
import
com.svi.webgde.restservice.object.XMLContents
;
import
com.svi.webgde.restservice.utils.XMLUtil
;
...
...
@@ -246,9 +247,9 @@ public class GDEWebServices {
try
{
File
file
=
new
File
(
xml
.
getOutputDir
());
if
(
file
.
exists
())
{
if
(
file
.
exists
())
{
XMLUtil
.
updateExceptionRmrk
(
xml
);
}
else
{
}
else
{
XMLUtil
.
generateXML
(
xml
);
}
...
...
@@ -260,5 +261,23 @@ public class GDEWebServices {
return
Response
.
ok
(
"Success"
).
build
();
}
@POST
@Path
(
"/fetch-local"
)
@Consumes
(
MediaType
.
APPLICATION_JSON
)
@Produces
(
MediaType
.
APPLICATION_OCTET_STREAM
)
public
Response
getFile
(
Request
request
)
{
// extract file path from file:// URL format
String
filePath
=
request
.
getDir
().
substring
(
"file://"
.
length
());
// read file from local file system
File
file
=
new
File
(
filePath
);
if
(!
file
.
exists
())
{
return
Response
.
status
(
Response
.
Status
.
NOT_FOUND
).
build
();
}
// return file contents in blob format with filename in content-disposition header
ResponseBuilder
response
=
Response
.
ok
(
file
);
response
.
header
(
"content-disposition"
,
"attachment; filename = "
+
file
.
getName
());
return
response
.
build
();
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment