wkhtmltoimage Could not find the ColdFusion component or interface base - coldfusion

I am trying to use wkhtmltoimage with Abram Adams image.cfc. I keep getting the error "Could not find the ColdFusion component or interface base". My code is below:
<cfscript>
wkhtmltoimage = new customdesigner.com.wkhtmltoimage(binaryPath = 'C:\Program Files\wkhtmltopdf\bin\wkhtmltoimage.exe');
image = wkhtmltoimage.create({
'html': '#trim(form.data)#',
'quality':'100',
'encoding': 'utf-8'
//writeToFile = true, // true will write the file and return a struct containing the path (and other info)
//destination = "#expandPath('..\media\client\images\L#session.locationcode#-#form.filename#-#session.uuid#.jpg')#"
});
</cfscript>
I know the executable path is correct because I use the same path for the htmltopdf and it works fine. What am I missing? Am I calling the component wrong?

Related

Using C++ dll file need to convert jpg into Webp using nodejs

I've searched stackoverflow and numerous websites for an answer to this. But I can't find any proper information regarding this. I am stuck.
I want to convert jpg into Webp by Using C++ dll file in nodejs. For this i Installed FFi Also, But getting error in Response. Can you Please Check my Code.
const ffi = require('ffi');
const ref = require('ref');
const fs = require('fs');
var int = ref.types.int ;
const dllFile = './WebpSdk.dll';
if (!fs.existsSync(dllFile)) {
throw (new Error('dll does not exist'));
}
const lib = ffi.Library(dllFile, {
'SelectSingleFile': [ 'bool', [ref.types.Object,ref.types.int] ]
});
const filepath ='./thumb/file.jpg';
console.log(lib.SelectSingleFile(filepath,1));//1 is FileType Like jpg
Getting this Error.
[nodemon] app crashed - waiting for file changes before starting...
C++ Dll Function SelectSingleFile Role.
//Select single file
BOOL bCheck = SelectSingleFile(PathName, ImageType);//SDK function
If bcheck true file is valid if false file is invalid.

C# AWS GetParametersByPathRequest (how to write code flexible, intelligent & sophisticated enough to handle paths regardless of the hierarchy level?)

The following packages are installed in my Visual Studio solution’s project:
Amazon.Extensions.Configuration.SystemsManager" Version="4.0.0"
Amazon.Lambda.APIGatewayEvents" Version="2.5.0"
Amazon.Lambda.Core" Version="2.1.0"
Amazon.Lambda.Serialization.SystemTextJson" Version="2.3.0"
AWSSDK.S3" Version="3.7.9.21"
AWSSDK.SecretsManager" Version="3.7.2.65"
AWSSDK.SecretsManager.Caching" Version="1.0.4"
Microsoft.Extensions.Configuration.EnvironmentVariables" Version="3.1.27"
Microsoft.Extensions.Configuration.FileExtensions" Version="3.1.27"
Microsoft.Extensions.Configuration.Json" Version="3.1.27"
Microsoft.Extensions.DependencyInjection" Version="3.1.27"
Microsoft.Extensions.Logging" Version="3.1.27"
Microsoft.Extensions.Logging.Console" Version="3.1.27"
starkbank-ecdsa" Version="1.3.3"
Swashbuckle.AspNetCore" Version="6.3.0"
Let’s say that my AWS Cloud account has the following parameters:
/bible/OldTestament/Law/Genesis/Chapter1
/bible/OldTestament/Law/Genesis/Chapter2
/bible/OldTestament/Law/Genesis/Chapter3
…..
/bible/OldTestament/Law/Exodus/Chapter1
/bible/OldTestament/Law/Exodus/Chapter2
…..
/bible/NewTestament/Gospel/Mark/Chapter1
/bible/NEwTestament/Gospel/Mark/Chapter2
…..
/bible/NewTestament/Gospel/John/Chapter1
/bible/NewTestament/Gospel/John/Chapter2
private GetParametersByPathResponse GetMyAppAWSParameters(string path)
{
GetParametersByPathRequest request = new GetParametersByPathRequest()
{
Path = path,
WithDecryption = false
};
return _ssm.GetParametersByPathAsync(request).Result;
}
The aforementioned method works with Paths that are just one-level up from the Leaf Node (i.e.,
path = /bible/OldTestament/Law/Genesis/
The returned response parameter list contains:
/bible/OldTestament/Law/Genesis/Chapter1
/bible/OldTestament/Law/Genesis/Chapter2
/bible/OldTestament/Law/Genesis/Chapter3
Or
path = /bible/NewTestament/Gospel/John/
The return response parameter list contains:
/bible/NewTestament/Gospel/John/Chapter1
/bible/NewTestament/Gospel/John/Chapter2
However, if I provide a shorter paths further up the hierarchy like the following:
path = /bible/OldTestament/Law/
Or
path = /bible/NewTestament/
Unfortunately The return response parameter list is empty
Essentially, I was trying to implement code that is flexible, intelligent & sophisticated enough to handle paths regardless of the hierarchy level.
Could someone please provide code that will allow me to do this?
It works when I set Recursive to true.
private GetParametersByPathResponse GetMyAppAWSParameters(string
path)
{
GetParametersByPathRequest request = new GetParametersByPathRequest()
{
Path = path,
Recursive = true,
WithDecryption = false
};
return _ssm.GetParametersByPathAsync(request).Result;
}

Remove uploaded files with filepond

I really enjoy the filepond library and would like to implement it in my flask app. Since I was not able to find any useful examples online, I started to write my own, small, proof of concept web application. I would like to upload multiple images to the server and save the filenames in the database. Furthermore, I would like to edit an entry and add additional files or remove the existing ones.
So far I figured out how to upload and revert files before the form is submitted. I am also able to load existing files inside the edit form. Just when I click the 'x' button on a loaded image inside the edit form the image is removed from the filepond window and a 'removefile' event is fired, but the file still remains on the server. Is it possible to trigger the revert request on a loaded file or is there a better solution altogether?
x-button does not remove the file from the server
Here are the relevant snippets from my js file:
FilePond.registerPlugin(
FilePondPluginFileValidateSize,
FilePondPluginImagePreview,
FilePondPluginFileRename,
FilePondPluginFileValidateType
);
inputElement = document.querySelector(".filepond");
token = document
.querySelector('input[name="csrf_token"]')
.getAttribute("value");
FilePond.setOptions({
server: {
headers: { "X-CSRF-TOKEN": token },
process: "./process",
revert: "./revert",
load: {
url: "../",
}
},
});
const filepond = FilePond.create(inputElement, {
// Here I pass the files to my edit form in the following format:
//
// files: [
// {
// source: 'static/images/some_name.png',
// options: {
// type: 'local'
// }
// }]
});
The relevant code from .py file:
#app.route("/process", methods=["POST"])
#app.route("/edit/process", methods=["POST"])
def process():
upload_dir = "static/images"
file_names = []
for key in request.files:
file = request.files[key]
picture_fn = file.filename
file_names.append(picture_fn)
picture_path = os.path.join(upload_dir, picture_fn)
try:
file.save(picture_path)
except:
print("save fail: " + picture_path)
return json.dumps({"filename": [f for f in file_names]})
#app.route("/revert", methods=["DELETE"])
#app.route("/edit/revert", methods=["DELETE"])
def revert():
upload_dir = "static/images"
parsed = json.loads(request.data)
picture_fn = parsed["filename"][0]
picture_path = os.path.join(upload_dir, picture_fn)
try:
os.remove(picture_path)
except:
print("delete fail: " + picture_path)
return json.dumps({"filename": picture_fn})
Here is the repository to my full flask-filepond app:
https://github.com/AugeJevgenij/flask_filepond
Please excuse me if the question is unclear, does not make sense or the code is written poorly.
I just started programming a few months ago.
Acording to filepond documentation you can remove a file stored locally on the server like this:
FilePond.setOptions({
server: {
remove: (source, load, error) {
// 'source' is the path of the file and should be sent to a server endpoint via http
// call the load method before ending the function
load()
}
}
})
then on your server where you receive the source (path), use it to delete the file. Keep in mind that this is a risky approach to get your website hacked!

PowerBI: Check if the folder/directory we are loading to exists or not using Power Query

I am a newbie in PowerBi and currently working on a POC where I need to load data from a folder or directory. Before this load, I need to check if
1) the respective folder exists
2) the file under the folder is with.csv extension.
Ex. Let suppose we have a file '/MyDoc2004/myAction.csv'.
Here first we need to check if MyDoc2004 exists and then if myAction file is with.csv extension.
Is there any way we can do this using Power Query?
1. Check if the folder exists
You can apply Folder.Contents function with the absolute path of the folder, and handle the error returned when the folder does not exist with try ... otherwise ... syntax.
let
absoluteFolderPath = "C:/folder/that/may/not/exist",
folderContentsOrError = Folder.Contents(absoluteFolderPath),
alternativeResult = """" & absoluteFolderPath & """ is not a valid folder path",
result = try folderContentsOrError otherwise alternativeResult
in
result
2. Check if the file is with .csv extension
I'm not sure what output you are expecting.
Here is a way to get the content of the file by full path including ".csv", or return an alternative result if not found.
let
absoluteFilePath = "C:/the/path/myAction.csv",
fileContentsOrError = File.Contents(absoluteFilePath),
alternativeResult = """" & absoluteFilePath & """ is not a valid file path",
result = try fileContentsOrError otherwise alternativeResult
in
result
If this is not what you are looking for, please update the question with the expected output.
Hope it helps.

How to skip unsupported image using cfimage processing?

I am using ColdFusion 10.
When trying to read some image files, ColdFusion returns no values and no error messages are shown.
I tried to re-size an image using cfimage tag. It is crashing. So I tried to get info about the image using "imageinfo" function. It returns blank. Please help me to either get some info or skip the image. Can anyone help me?
I tried reading the file which caused the anomaly using
<cfimage action="read" source="full pathname" name="image">
<cfset image = imageRead(full pathname)>
and many other ColdFusion documented functions. No error was shown. No output was obtained. I used cffile which showed unsupported file type error.
<cffile
action = "readBinary" file = "full pathname" variable = "variable name"
>
Thanks Rino
Try using this function for reading images.
<cfimage> tag or imageNew() can have issues while trying to read image files which are corrupted or files saved with changed extensions (background transparent .png files saved as .jpeg) while uploading.
I think the main problem with these files is that there is a chance coldfusion doesn't throw an error of any sort when we try to read files mentioned above.
<cfscript>
public function readImage(fullpath){
//trying java imageio
var imageFile = createObject("java", "java.io.File").init(fullpath);
// read the image into a BufferedImage
var ImageIO = createObject("java", "javax.imageio.ImageIO");
try {
var bi = ImageIO.read(imageFile);
return ImageNew(bi);
} catch(any e) {
//try for bad formatted images
//create java file object, passing in path to image
var imageFile = createObject("java","java.io.File").init(fullpath);
//create a FileSeekableStream, passing in the image file we created
var fss = createObject("java","com.sun.media.jai.codec.FileSeekableStream").init(imageFile);
//create ParameterBlock object and initialize it (call constructor)
var pb = createObject("java","java.awt.image.renderable.ParameterBlock").init();
//create JAI object that will ultimately do the magic we need
var JAI = createObject("java","javax.media.jai.JAI");
try {
//pass in FileSeekableStream
pb.add(fss);
//use the JAI object to create a buffered jpeg image.
var buffImage = local.JAI.create("jpeg", pb).getAsBufferedImage();
//pass the buffered image to the ColdFusion imagenew()
var New_Image = imagenew(buffImage);
//make sure we close the stream
fss.close();
return New_Image;
} catch (any e) {
if (isDefined("fss")) {
fss.close();
}
rethrow;
}
}
}
</cfscript>