How we able to get bank logos in getsite accounts api ?
I want to display account logo in searchaccount API call.
Which API will return this detail?
You need to use get getSiteInfo API and remember to pass value of siteFilter.reqSpecifier as 128, while if you are using SOAP then here is the reference(remember to pass request specifier as 128).
EDIT 1: Based on the comment
You can use this code to convert the Base64 string to image.
Below is the code in JAVA:
public static BufferedImage decodeToImage(String imageString) {
BufferedImage image = null;
byte[] imageByte;
try {
BASE64Decoder decoder = new BASE64Decoder();
imageByte = decoder.decodeBuffer(imageString);
ByteArrayInputStream bis = new ByteArrayInputStream(imageByte);
image = ImageIO.read(bis);
bis.close();
} catch (Exception e) {
e.printStackTrace();
}
return image;
}
Related
I am trying to upload a file to OneDrive special folder using the java sdk but I am getting the following error
Error code: BadRequest Error message: Multiple action overloads were found with the same binding parameter for 'microsoft.graph.createUploadSession'.
Here is a snippet of the java code I am using
private void uploadFile(IGraphServiceClient graphClient, File localFile, String onedriveFileName) throws IOException, InterruptedException {
// Get an input stream for the file
InputStream fileStream = new FileInputStream(localFile);
long streamSize = localFile.length();
// Create a callback used by the upload provider
IProgressCallback<DriveItem> callback = new IProgressCallback<DriveItem>() {
#Override
// Called after each slice of the file is uploaded
public void progress(final long current, final long max) {
LOGGER.trace(String.format("Uploaded %d bytes of %d total bytes", current, max));
}
#Override
public void success(final DriveItem result) {
LOGGER.info(String.format("Uploaded file with ID: %s", result.id));
}
public void failure(final ClientException ex) {
LOGGER.error(String.format("Error uploading file: %s", ex.getMessage()));
}
};
try {
// Create an upload session
UploadSession uploadSession = graphClient
.me()
.drive().special("approot")
.itemWithPath(onedriveFileName)
.createUploadSession(new DriveItemUploadableProperties())
.buildRequest()
.post();
ChunkedUploadProvider<DriveItem> chunkedUploadProvider =
new ChunkedUploadProvider<DriveItem>
(uploadSession, graphClient, fileStream, streamSize, DriveItem.class);
// Config parameter is an array of integers
// customConfig[0] indicates the max slice size
// Max slice size must be a multiple of 320 KiB
int[] customConfig = {320 * 1024};
// Do the upload
chunkedUploadProvider.upload(callback, customConfig);
} catch(IOException ex){
throw ex;
} catch (Exception ex) {
throw ex;
}
}
Any help appreciated.
Thanks
My issue is that I had special characters in the filename, removing them fixed it for me.
I'm starting a new project and adopting spring webflux as reactive rest framework. I have a use case that return captcha image at the backend. I have a sample code as below which generate captcha image and return with spring framework but now I have no idea how to return the image with reactive way.
This is my use case in Spring MVC way:
#RequestMapping(value="/captcha/{id:.+}", produces = MediaType.IMAGE_JPEG_VALUE)
public #ResponseBody byte[] captcha(#PathVariable("id") String captchaId, HttpServletResponse res) throws Exception{
try{
byte [] captchaImg = (byte[])cacheService.getValue(captchaId, AuthConstants.CACHE_CAPTCHA_IMG_KEY);
return captchaImg;
}catch(Exception e){
res.setStatus(HttpStatus.NOT_FOUND.value());
return null;
}
}
In reactive way which is failure code as below:
public Mono<ServerResponse> captchaImage(ServerRequest request) {
return Mono.just(request.pathVariable("id"))
.flatMap(id->cacheService.getValue(id, AuthConstant.CACHE_CAPTCHA_IMG_KEY))
.flatMap(captchaImage-> {
System.out.println("img:"+captchaImage);
return ServerResponse
.ok()
.contentType(MediaType.IMAGE_JPEG)
.body(BodyInserters.fromObject(captchaImage));
});
}
This code is failure and I can't find any information to get idea how to do it.
I need your help. Appreciate that you can provide some snippet code.
Thanks
I think I found an answer.
public Mono<ServerResponse> captchaImage(ServerRequest request) {
return Mono.just(request.pathVariable("id"))
//get the image from redis in byte[]
.flatMap(id->genericHashOperations.opsForHash().get(id,AuthConstant.CACHE_CAPTCHA_IMG_KEY)
.flatMap(cimg->{
byte[] i = (byte[]) cimg;
//use data Buffer to wrap the image in byte array
DataBuffer buffer = new DefaultDataBufferFactory().wrap(i);
return ServerResponse
.ok()
.contentType(MediaType.IMAGE_JPEG)
.body(BodyInserters.fromDataBuffers(Flux.just(buffer)));
}));
}
I have an sha256 hash and my goal is to sign it with CoSign SOAP API. Could you provide me a Java example? The PDF Signing example is working like a charm, but it's not perfectly clear for me, how should I set the InputDocument for this task.
Thanks a lot!
The code example below demonstrates how to sign a hash value using CoSign Signature SOAP API. However, I would strongly recommend to use CoSign Signature API instead, which is richer in its functionality and is way more intuitive.
public static byte[] SAPIWS_SignHash(byte[] data, String username, String domain, String password) throws Exception
{
byte[] signedHash = null;
try {
// Set hash method & data
DocumentHash documentHash = new DocumentHash();
DigestMethodType digestMethod = new DigestMethodType();
digestMethod.setAlgorithm("http://www.w3.org/2001/04/xmlenc#sha256");
documentHash.setDigestMethod(digestMethod);
documentHash.setDigestValue(data);
// Set user credentials
ClaimedIdentity claimedIdentity = new ClaimedIdentity();
NameIdentifierType nameIdentifier = new NameIdentifierType();
nameIdentifier.setValue(username);
nameIdentifier.setNameQualifier(domain);
CoSignAuthDataType coSignAuthData = new CoSignAuthDataType();
coSignAuthData.setLogonPassword(password);
claimedIdentity.setName(nameIdentifier);
claimedIdentity.setSupportingInfo(coSignAuthData);
// Build complete request object
SignRequest signRequest = new SignRequest();
RequestBaseType.InputDocuments inputDocs = new RequestBaseType.InputDocuments();
inputDocs.getOtherOrTransformedDataOrDocument().add(documentHash);
RequestBaseType.OptionalInputs optionalParams = new RequestBaseType.OptionalInputs();
optionalParams.setSignatureType("urn:ietf:rfc:2437:RSASSA-PKCS1-v1_5");
optionalParams.setClaimedIdentity(claimedIdentity);
signRequest.setOptionalInputs(optionalParams);
signRequest.setInputDocuments(inputDocs);
// Initiate service client
DSS client = new DSS(new URL("https://prime.cosigntrial.com:8080/sapiws/dss.asmx"));
// Send the request
DssSignResult response = client.getDSSSoap().dssSign(signRequest);
// Check response output
if ("urn:oasis:names:tc:dss:1.0:resultmajor:Success".equals(response.getResult().getResultMajor())) {
// On success- return signature buffer
ResponseBaseType.OptionalOutputs doc = response.getOptionalOutputs();
signedHash = doc.getDocumentWithSignature().getDocument().getBase64Data().getValue();
}
else {
throw new Exception(response.getResult().getResultMessage().getValue());
}
}
catch (Exception e)
{
System.out.println("Error: " + e.getMessage());
e.printStackTrace();
}
return signedHash;
}
Very need M (Manual) Exposure mode on QX1. I was searching for an answer to the my question, but don't found the exact answer. Can I choose the full manual Exposure mode on QX1 via API?
No, you can't set Manual mode with the current firmware on a QX1 camera.
You are supposed to use the getAvailableExposureMode or getSupportedExposureMode API methods to retrieve the supported modes (and optionally display them to the user), then use one of only those modes in setExposureMode.
But Manual mode is not supported by the QX1 camera, so it's not returned by the getSupported/Available methods and that's why the API returns the error to the setExposureMode call.
The API is intended to support several SONY cameras with several different features. For each property you have the following API methods:
getSupportedProperty -> Returns the property values supported by the camera.
getProperty -> Returns the actual value for the property
setProperty -> Allows to set a new value for the property
getAvailableProperty -> Returns current value and supported values.
That way, if the app is well coded it will support all the cameras.
So, it's not an API problem but a firmware one. The current firmware for the QX1 does not support Manual mode.
There's not an official firmware update yet :(
https://esupport.sony.com/US/p/model-home.pl?mdl=ILCEQX1&LOC=3#/downloadTab
have you tried this found here : https://github.com/erik-smit/sony-camera-api/blob/master/actEnableMethods.sh
other references to this hack here: http://chdk.setepontos.com/index.php?topic=10736.10
i could not get it to work but if it can help in your research in any way
public String getDG() throws IOException {
String service = "accessControl";
try {
JSONObject paramsMethods =
new JSONObject().put("developerName","");
paramsMethods.put("sg","");
paramsMethods.put("methods","");
paramsMethods.put("developerID","");
JSONObject requestJson =
new JSONObject().put("method", "actEnableMethods") //
.put("params", new JSONArray().put(paramsMethods)) //
.put("id", id()).put("version", "1.0");
String url = findActionListUrl(service) + "/" + service;
log("Request: " + requestJson.toString());
String responseJson = SimpleHttpClient.httpPost(url, requestJson.toString());
log("Response: " + responseJson);
JSONArray resultsObj = new JSONObject(responseJson).getJSONArray("result");
String dg = null;
JSONObject dgobj = resultsObj.getJSONObject(0);
dg = dgobj.getString("dg");
return dg;
} catch (JSONException e) {
throw new IOException(e);
}
}
public String getSG(String dg){
MessageDigest md;
String keydg = "90adc8515a40558968fe8318b5b023fdd48d3828a2dda8905f3b93a3cd8e58dc" + dg;
try {
md = MessageDigest.getInstance("SHA-256");
md.update(keydg.getBytes());
String SG = new String(Base64.encode(md.digest(), 0));
return SG;
}catch(Exception e){
}
return null;
}
public JSONObject actEnableMethods() throws IOException {
String DG = getDG();
String SG = getSG(DG);
String service = "accessControl";
try {
JSONObject paramsMethods =
new JSONObject().put("developerName","Sony Corporation");
paramsMethods.put("sg",SG);
paramsMethods.put("methods","camera/setFlashMode:camera/getFlashMode:camera/getSupportedFlashMode:camera/getAvailableFlashMode:camera/setExposureCompensation:camera/getExposureCompensation:camera/getSupportedExposureCompensation:camera/getAvailableExposureCompensation:camera/setSteadyMode:camera/getSteadyMode:camera/getSupportedSteadyMode:camera/getAvailableSteadyMode:camera/setViewAngle:camera/getViewAngle:camera/getSupportedViewAngle:camera/getAvailableViewAngle:camera/setMovieQuality:camera/getMovieQuality:camera/getSupportedMovieQuality:camera/getAvailableMovieQuality:camera/setFocusMode:camera/getFocusMode:camera/getSupportedFocusMode:camera/getAvailableFocusMode:camera/setStillSize:camera/getStillSize:camera/getSupportedStillSize:camera/getAvailableStillSize:camera/setBeepMode:camera/getBeepMode:camera/getSupportedBeepMode:camera/getAvailableBeepMode:camera/setCameraFunction:camera/getCameraFunction:camera/getSupportedCameraFunction:camera/getAvailableCameraFunction:camera/setLiveviewSize:camera/getLiveviewSize:camera/getSupportedLiveviewSize:camera/getAvailableLiveviewSize:camera/setTouchAFPosition:camera/getTouchAFPosition:camera/cancelTouchAFPosition:camera/setFNumber:camera/getFNumber:camera/getSupportedFNumber:camera/getAvailableFNumber:camera/setShutterSpeed:camera/getShutterSpeed:camera/getSupportedShutterSpeed:camera/getAvailableShutterSpeed:camera/setIsoSpeedRate:camera/getIsoSpeedRate:camera/getSupportedIsoSpeedRate:camera/getAvailableIsoSpeedRate:camera/setExposureMode:camera/getExposureMode:camera/getSupportedExposureMode:camera/getAvailableExposureMode:camera/setWhiteBalance:camera/getWhiteBalance:camera/getSupportedWhiteBalance:camera/getAvailableWhiteBalance:camera/setProgramShift:camera/getSupportedProgramShift:camera/getStorageInformation:camera/startLiveviewWithSize:camera/startIntervalStillRec:camera/stopIntervalStillRec:camera/actFormatStorage:system/setCurrentTime");
paramsMethods.put("developerID","7DED695E-75AC-4ea9-8A85-E5F8CA0AF2F3");
JSONObject requestJson =
new JSONObject().put("method", "actEnableMethods") //
.put("params", new JSONArray().put(paramsMethods)) //
.put("id", id()).put("version", "1.0");
String url = findActionListUrl(service) + "/" + service;
log("Request: " + requestJson.toString());
String responseJson = SimpleHttpClient.httpPost(url, requestJson.toString());
log("Response: " + responseJson);
return new JSONObject(responseJson);
} catch (JSONException e) {
throw new IOException(e);
}
}
It seems you can. Per the table here, you can set the Exposure Mode on the QX1. You can use the setExposureMode API method with something like the following JSON:
{
"method": "setExposureMode",
"params": ["Manual"],
"id": 1,
"version": "1.0"
}
Source:
API Reference downloaded from https://developer.sony.com/develop/cameras/get-started/
I have an RPC service and one of the method is generating a report using Pentaho Reporting Engine. Report is an PDF file. What I'd like to do, is when user request a report, the report is sent back to him and save dialog or sth pops up. I tried this inside my service method:
Resource res = manager.createDirectly(new URL(reportUrl), MasterReport.class);
MasterReport report = (MasterReport) res.getResource();
report.getParameterValues().put("journalName", "FooBar");
this.getThreadLocalResponse().setContentType("application/pdf");
PdfReportUtil.createPDF(report, this.getThreadLocalResponse().getOutputStream());
But it doesn't work. How it can be done?
I do it a little bit differently. I've got a separate servlet that I use to generate the PDF. On the client, do something like:
Cookies.setCookie(set what ever stuff PDF needs...);
Window.open(GWT.getModuleBaseURL() + "DownloadPDF", "", "");
The servlet, DownloadPDF looks something like this:
public class DownloadPDF extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response) {
Cookie[] cookies = request.getCookies();
try {
// get cookies, generate PDF.
// If PDF is generated to to temp file, read it
byte[] bytes = getFile(name);
sendPDF(response, bytes, name);
} catch (Exception ex) {
// do something here
}
}
byte[] getFile(String filename) {
byte[] bytes = null;
try {
java.io.File file = new java.io.File(filename);
FileInputStream fis = new FileInputStream(file);
bytes = new byte[(int) file.length()];
fis.read(bytes);
} catch (Exception e) {
e.printStackTrace();
}
return bytes;
}
void sendPDF(HttpServletResponse response, byte[] bytes, String name) throws IOException {
ServletOutputStream stream = null;
stream = response.getOutputStream();
response.setContentType("application/pdf");
response.addHeader("Content-Type", "application/pdf");
response.addHeader("Content-Disposition", "inline; filename=" + name);
response.setContentLength((int) bytes.length);
stream.write(bytes);
stream.close();
}
}