Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 17 days ago.
This post was edited and submitted for review 13 days ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
We send emails via the Admin API, with PDF attachments the PDF is then unreadable, with TXT files there is no problem.
Doku: https://shopware.stoplight.io/docs/admin-api/743f0819350c4-send-a-mail
Request-URL: _action/mail-template/send
We use the binAttachments parameter set as follows.
The "content" is fetched and without BASE64 encoding the JSON code is corrupt, if you encode it the mail can be sent. But the attachment is not valid with/without encoding.
$content = file_get_contents()
$binAttachments[] = ["content" => base64_encode($content),
"fileName" => 'test.pdf',
"mimeType" => 'application/pdf'
];
No decode is done in the API controller, here is my suggestion for change?
Adjustment of the controller
\Shopware\Core\Content\MailTemplate\Api\MailActionController
public function send(RequestDataBag $post, Context $context): JsonResponse
direkt nach der Zeile
$data = $post->all();
/optionale Decodierung des Strings, falls es ein BASE64 ist/
foreach ($data['binAttachments'] as &$binAttachment) {
if (base64_decode($binAttachment['content'], true)) {
// is valid $binAttachment['content'] = base64_decode($binAttachment['content']);
} else {
// not valid, Nothing to do
}
}
In addition, an issue has already been created:
https://issues.shopware.com/issues/NEXT-25189
Description see above
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have create One API controller and i want to pass custom error class object as a response.
Can any one help me for that ?
Thanks in advance.
Create one class for to store error information as shown below.
ErrorInformation objError = new ErrorInformation();
try
{
test(ref Token, ref SessionToken);
}
catch (Exception ex)
{
objError.ErrorMessage = ex.Message;
objError.StatusCode = Convert.ToInt16(HttpStatusCode.ExpectationFailed);
objError.ErrorType = ex.GetType().ToString();
objError.ErrorCode = "E01";
throw new HttpResponseException(Request.CreateResponse<ErrorInformation>(HttpStatusCode.ExpectationFailed, objError));
}
This will return whole object as result.
{
"StatusCode": 417,
"ErrorMessage": "Error Detail",
"ErrorType": "System.DivideByZeroException",
"ErrorCode": "E01"
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking for a plagiarism checker API that is based on C# code. I need to use it on my web service. I need to easily query plagiarism checking engine and get result for the originality of the text.
If you know any service that is similar to what I am asking it would be great!
I’m using an online plagiarism checker service called Copyleaks which offers an interface to integrate with their API (HTTP REST). It also provides interface which is fully compatible with C#.
Steps to integrate with Copyleaks API:
Register on Copyleaks website.
Create a new C# Console application project and install Copyleaks’ Nuget Package.
Use the following code which performs a webpage scan.
This code was taken from its SDK (GitHub):
public void Scan(string username, string apiKey, string url)
{
// Login to Copyleaks server.
Console.Write("User login... ");
LoginToken token = UsersAuthentication.Login(username, apiKey);
Console.WriteLine("\t\t\tSuccess!");
// Create a new process on server.
Console.Write("Submiting new request... ");
Detector detector = new Detector(token);
ScannerProcess process = detector.CreateProcess(url);
Console.WriteLine("\tSuccess!");
// Waiting to process to be finished.
Console.Write("Waiting for completion... ");
while (!process.IsCompleted())
Thread.Sleep(1000);
Console.WriteLine("\tSuccess!");
// Getting results.
Console.Write("Getting results... ");
var results = process.GetResults();
if (results.Length == 0)
{
Console.WriteLine("\tNo results.");
}
else
{
for (int i = 0; i < results.Length; ++i)
{
Console.WriteLine();
Console.WriteLine("Result {0}:", i + 1);
Console.WriteLine("Domain: {0}", results[i].Domain);
Console.WriteLine("Url: {0}", results[i].URL);
Console.WriteLine("Precents: {0}", results[i].Precents);
Console.WriteLine("CopiedWords: {0}", results[i].NumberOfCopiedWords);
}
}
}
Call the function with your Username, API-Key and the URL of the content you wish to scan for plagiarism.
You can read more about its server in "How To" tutorial.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I Already done updating the password in database using SQLAdpaters in IBM Worklight Hybrid App.
I am Working on Hybrid App using IBM Worklight. I am updating user password in database using SQLAdapter, but I want to store password in encrypted format. I already have the encryption and decryption logic in java class. How can I integrate that java class with my hybrid app?
var procedure1Statement = WL.Server.createSQLStatement("UPDATE USERS SET USERPASSWORD=? WHERE USERNAME = ? AND USERPASSWORD=? ");
function updateUserPassword(newPassword,userName,password) {
return WL.Server.invokeSQLStatement({
preparedStatement : procedure1Statement,
parameters : [newPassword,userName,password]
});
}
changed code as follows
var userpwdUpdateStatement = WL.Server.createSQLStatement("UPDATE USERS SET USERPASSWORD=? WHERE USERNAME = ? AND USERPASSWORD=? ");
function updateUserPassword(newPassword,userName,password) {
var encryptdecryptutility = new com.abcd.bgf.SysCRAESencrpDecrp();
var encryptnewPassword = encryptdecryptutility.encrypt(newPassword);
var encryptoldPassword = encryptdecryptutility.encrypt(password);
return WL.Server.invokeSQLStatement({
preparedStatement : userpwdUpdateStatement,
parameters : [encryptnewPassword,userName,encryptoldPassword]
});
}
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 9 years ago.
Improve this question
Is there a way to extract a zip file into the computer's memory at runtime (e.g. to extract a picture but put it temporarily in the memory and place it on a PictureBox)
LIBRARIES ARE ALLOWED.
I think this should work.(not tested)
Requires .net 4.5(System.IO.Compression.dll)
using System.IO.Compression;
...
byte [] pictureBuffer = null;
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (var entry in archive.Entries)
{
if(entry.FullName == "SomePicture")
{
using (zipEntryStream = entry.Open())
using (MemoryStream memStream = new MemoryStream())
{
zipEntryStream.CopyTo(memStream);
pictureBuffer = zipEntryStream.ToArray;
}
}
}
I think this should work.(not tested)
using the DotNetZip Library http://www.nuget.org/packages/DotNetZip/
using (ZipFile zip = new ZipFile(zipPath))
{
foreach (var entry in zip.Entries)
{
if(entry.FileName == "SomePicture")
{
using (var zipEntryStream = entry.OpenReader())
using (var memStream = new MemoryStream())
{
zipEntryStream.CopyTo(memStream);
pictureBuffer = zipEntryStream.ToArray;
}
}
}
}
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Is there any framework that will allow me to send email without going through a GUI?
Add this framework to your project and then use my Swift class:
class EmailSender : SKPSMTPMessageDelegate {
private init() {}
static let sharedInstance = EmailSender();
func sendEmail(email : String, subject : String, message : String) {
let EMAIL_FROM = "test#gmail.com";
let EMAIL_PASS = "TestPassword";
let SMTP_SERVER = "smtp.gmail.com";
let EMAIL_TO = email;
let emailMessage = SKPSMTPMessage();
emailMessage.delegate = self;
emailMessage.fromEmail = EMAIL_FROM;
emailMessage.toEmail = EMAIL_TO;
emailMessage.relayHost = SMTP_SERVER;
emailMessage.requiresAuth = true;
emailMessage.login = EMAIL_FROM;
emailMessage.pass = EMAIL_PASS;
emailMessage.subject = subject;
emailMessage.wantsSecure = true;
let plainMsg = [
kSKPSMTPPartContentTypeKey : "text/plain",
kSKPSMTPPartMessageKey : message,
kSKPSMTPPartContentTransferEncodingKey : "8bit"
];
emailMessage.parts = [plainMsg];
emailMessage.send();
}
//MARK SKPSMTPMessageDelegate
#objc func messageSent(_ message: SKPSMTPMessage!) {
}
#objc func messageFailed(_ message: SKPSMTPMessage!, error: Error!) {
}
}
You should check out the SKPSMTPMessage framework. This allows you to send emails in the background. http://code.google.com/p/skpsmtpmessage/ It is not possible to do so yet, unless you code around MFMailComposeViewController which would presumably get your app rejected from the store (iOS5.0)
If you don't need to have the email sent from the iPhone users mail app, you could offload the action to a server and have the server mail it on the users behalf.
The only problem with this is that you may have spam issues depending on what service you use (Mail Chimp etc...).