How to use base64 string in Google pass event ticket logo - android-pay

I am using Google Passes API and creating Passes using C#. I want to use base64 string for event ticket logo but not getting any option for that. Is there any possibility that we can use base64 string for event ticket logo
payload.Logo = new Image();
payload.Logo.SourceUri = new ImageUri();
payload.Logo.SourceUri.Uri = "HTTP://www.example.com/test.jpg";

No option to do this, must be URI:
{
"uri": string,
"description": string,
"localizedDescription": {
object (LocalizedString)
}
}

Related

DocuSign REST API DELETE method requires a body

For example to remove a member from a signing group you call:
/restapi/v2/accounts/1686083/signing_groups/{groupId}/users
and provide:
{
"users": [
{
"userName": "sample string 1",
"email": "sample string 2"
}
]
}
as the body
But my REST object (in ServiceNow) does not allow me to provide a body when I'm using the delete method. Am I just stuck?
I don't think there is any another way to remove the user from a SigningGroup using API. You can try to update the user in a Signing group to a Dummy Email so that original user will not get email for signing. And once in a while DS Admin can go to WEBApp and manually delete it, if Service now is not allowing DS API delete operation with a body.
If you're using RestMessageV2 in ServiceNow scripted Outbound REST, there's a setRequestBody method you can use to set the request body as a string:
Example in the docs here
var sm = new sn_ws.RESTMessageV2("Update user","post");
var body = "{ ...Message body content... }";
sm.setRequestBody(body);

Generate a QR Code in ASP.NET C# without using a 3rd party provider

I'm using ASP.NET identity 2 and one of the tutorials includes using a 3rd part provider to generate a QR Code for Google authenticator for two-factor authentication. However, I don't want to send that data to a 3rd party (which is what other solutions point to, like google, etc). I'm specifically looking for code to solve my issue.
I'd like either the server or the client to generate the QR Code. Anyone else have a good solution for doing this? Below is the line of code that generates the QR Code in the cshtml file. The #(Model.BarcodeURL) is the razor model attribute with the data for the QR Code.
<img src="http://qrcode.kaywa.com/img.php?s=4&d=#(Model.BarcodeUrl)" />
I was able to do this on the server using ZXing.Net and exposing an endpoint via a controller(MVC or Web API). The endpoint would receive data via query string and generate a QRCode on the server using ZXing.Net, then send it back as a stream. This allows one to show the code as an image.
<img src="http://localhost/barcode?d=#(Model.BarcodeUrl)" />
A MVC controller for the above src could look something like this.
....
using ZXing;
using ZXing.QrCode;
using ZXing.QrCode.Internal;
using System.Windows.Media.Imaging // for SaveJpeg extension
....
public class BarcodeController : Controller {
readonly IBarcodeWriter qrCodeWriter;
BarcodeController() {
qrCodeWriter = new BarcodeWriter {
Format = BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions {
Margin = 1,
Height = 600,
Width = 600,
ErrorCorrection = ErrorCorrectionLevel.Q,
},
};
}
public ActionResult Index(string d) {
var writeableBitmap = qrCodeWriter.Write(d);
var memoryStream = new MemoryStream();
writeableBitmap.SaveJpeg(memoryStream, writeableBitmap.PixelWidth, writeableBitmap.PixelHeight, 0, 100);
return File(memoryStream.GetBuffer(), "image/jpeg");
}
}
Should be easy enough to do the same thing via an ApiController. You could also refactor out the code generation into a dedicated class if you want to separate concerns.

Vaadin: Opening a new window with PDF content placed in a String variable

I'd like to open a new window with PDF content that is placed within a String variable.
I already have a button with an event connected. In this event I want to call the new window.
The method looks like this:
private void show_archivobjekt(String data) {
String pdf = anfrage.get_archivobjectdata(data);
System.out.println(pdf); // This shows my PDF content in console and works!
// How to convert this String into a StreamSource
StreamResource streamResource = new StreamResource(pdfss, "test.pdf", myView);
streamResource.setCacheTime(5000);
streamResource.setMIMEType("application/pdf");
myView.getMainWindow().open(streamResource, "_blank");
}
myView is the Application.
How can I convert the String pdf to a StreamSource (pdfss)? Do I have to save it as file at first or is it possible to convert it to a StreamSource directly in memory?
The console output shows me the typically PDF content starting with %PDF-1.3 ... and so on.
Any help would be appreciated. Thanks in advance!
Rainer
The answer to this question is available through the official support forum here: https://vaadin.com/forum#!/thread/148544
Simply create your StreamResource like this, by using the byte representation of your string to create a ByteArrayInputStream as the source:
StreamResource streamResource = new StreamResource(
new StreamResource.StreamSource() {
public InputStream getStream() {
return new ByteArrayInputStream(pdf.getBytes());
}
}, "test.pdf");

deserializing string array in c# for wp7

This is the structure of my JSON:
string sample =
"[{'Disp_Name':'avi garg',
'emailId':'avi#india.com',
'fName':'avi',
'lName':'garg',
'ph':{'number':'9813612344(Mobile)','type':1}
},
{'Disp_Name':'monk gup',
'emailId':'mon#india.com',
'fName':'monk',
'lName':'gup',
'ph':{'number':'01127243480(home)','type':2}
}]";
And I want to deserialize it back to an object array of my class. Can anyone please help me out in doing that? I would like to use datacontractjsonserializer preferably but others are also fine.
Thanking you
public static List<your class> decrypt_json(string json)
{
var deserializedUser = new List<your class>();
MemoryStream ms = new MemoryStream(Encoding.UTF8.GetBytes(json));
DataContractJsonSerializer ser=new DataContractJsonSerializer(deserializedUser.GetType());
deserializedUser = ser.ReadObject(ms) as List<your class>;
MessageBox.Show(deserializedUser.Count().ToString());
ms.Close();
return deserializedUser;
}

appcelerator titanium base64 encode blob objects

I am developing a mobile (iphone/android) application using appcelerator titanium (sdk 1.6.2).
At a certain point in the app the user choses an image that should be shown in an imageView, base64 encoded, then uploaded to my server.
The problem is the success event of the photo gallery returns the selected image as a blob object and the Titanium.Utils.base64encode method only accepts string values!
Is there any way to convert Titanium.Blob objects to strings?
Here is the code snippet:
var imageView = Titanium.UI.createImageView({
height:200,
width:200,
top:20,
left:10,
backgroundColor:'#999'
});
Titanium.Media.openPhotoGallery({
success:function(event)
{
var cropRect = event.cropRect;
var image = event.media;//blob object
// set image view
Ti.API.debug('Our type was: '+event.mediaType);
if(event.mediaType == Ti.Media.MEDIA_TYPE_PHOTO)
{
imageView.image = image;// this works
var imgStr=Ti.Utils.base64encode(image);// doesn't work because 'image' has to be a string!, but how?
}
else
{
}
Titanium.API.info('PHOTO GALLERY SUCCESS cropRect.x ' + cropRect.x + ' cropRect.y ' + cropRect.y + ' cropRect.height ' + cropRect.height + ' cropRect.width ' + cropRect.width);
},
allowEditing:true,
popoverView:popoverView,
arrowDirection:arrowDirection,
mediaTypes:[Ti.Media.MEDIA_TYPE_VIDEO,Ti.Media.MEDIA_TYPE_PHOTO]
});
Thank you,
var imgStr=Ti.Utils.base64encode(image.toString());
.toString() converts something to a string representation
This worked for me.
var image = event.media;
var imgStr = Ti.Utils.base64encode(image).toString();
i just posted some code for a module to do this conversion, I know a patch is coming from appcelerator, but the module might be useful to you now.
Clearly Innovative Thoughts - Titanium Appcelerator Quickie: base64encode iOS Module

Resources