how to upload image in correct path - image: Property "image" expects a valid pathname as data in akeneo - path

i already installed akeneo 2.0
I need to upload an image via Xl file
but I give the path
showing
Warning
image: Property "image" expects a valid pathname as data, "/tmp/pim/upload_tmp_dir/01.png" given.
how I can solve this???

In order to import images while import products, you will have to include it in your zip archive, and use its relative path (compared to your product import file) in the archive.
e.g if your archive file has the following structure:
- products_import.xlsx
- images/
image1.png
you will have to put ./images/image1.png in the image column of your products_import.xlsx file
Then upload the zip archive (instead of only the Excel file) in the import profile:

Related

How do you load a file (.csv) into a Beeware/Briefcase application?

I am using kivy as the GUI and Briefcase as a packaging utility. My .kv file is in the appname/project/src/projectName/resources folder. I also need a .csv file, in the same folder, and want to use pandas with it. I have no problem with importing the packages (I added them to the .toml file). I can't use the full path because when I package the app, the path will be different on each computer. Using relative paths to the app.py file does not work, giving me a file not found error. Is there a way to read a file using a relative path (maybe the source parameter in the .toml file)?
kv = Builder.load_file('resources/builder.kv')
df = pd.read_csv('resources/chemdata.csv')
class ChemApp(App):
def build(self):
self.icon = 'resources/elemental.ico'
return kv
I just encountered and solved a similar problem with Briefcase, even though I was using BeeWare's Toga GUI.
In my case, the main Python file app.py had to access a database file resources/data.csv. In the constructor of the class where I create a main window in app.py, I added the following lines (The import line wasn't there, but included here for clarification):
from pathlib import Path
self.resources_folder = Path(__file__).joinpath("../resources").resolve()
self.db_filepath = self.resources_folder.joinpath("data.csv")
Then I used self.db_filepath to successfully open the CSV file on my phone.
__file__ returns the path to the current file on whatever platform or device.

jpg images without extension aren't displayed

from kivy.uix.image import Image
self.img = Image(source="image") # This works when image is an PNG image
self.img = Image(source="image.jpg") # This works when image.jpg is a JPG image
self.img = Image(source="image") # This doesn't work when image is a JPG image
I need to specify images without extention for the app to be generic (working with more image types). Can I achieve it somehow?
Kivy is using "imghdr" to determine the image type here, and as a fallback it uses the file extension here.
That explains why the image loads fine when it has a file extension, even though "imghdr" can't find the file type in the file's content.
I tested on a list of JPEG files, and each time "imghdr" was able to detect the file type each time. That is done here im imghdr. Notably, "imghdr" does not consider the file extension.
$ python
>>> import os, imghdr
... for f in os.listdir('.'):
... print('%s -- %s' % (f, imghdr.what(f)))
Maybe the JPEG file is missing the "JFIF" or "Exif" string that imghdr is looking for? You could use hexedit to see if one of those string is present at Byte 6 of the image file.

List of files in flutter

I have images and I want to load them to my appplication.
my_app/lib/... - here my source files
my_app/assets/images/... - here my images
I need to get list of files in assets/images/ and after that show some of them (according to other logic)
I'm trying this
final dir = Directory("assets/images/");
print(dir.existsSync()); // <---- it also print: false
var files = dir.listSync().toList();
files.forEach((e) => list.add(MyImageItem(e.path)));
The problem is: I recieve exception
FileSystemException: Directory listing failed, path = 'assets/images/'
(OS Error: No such file or directory, errno = 2)
I've tried different ways: assets/images/, images/, images and so on
My pubspec.yaml
flutter:
assets:
- assets/images/
- assets/
When I create Image directly all is fine
new Image(image: AssetImage("assets/images/cat.png"))
I knew that previously (month ago) each resource has to be declared in pubspec.yaml directly, but now assets/images/ is ok.
I can load file by direct path. Why I can't access a directory? How to get list of files in directory to get them from my code?
When you add files to your assets, it means that you already know their paths.
Store all the images paths in a list and access them whenever you need.
For example if you have 3 images in
your_app/assets/images/image1.jpg
your_app/assets/images/image2.jpg
your_app/assets/images/image3.jpg
create a list and store all of them like:
List<String> imagePaths = ['assets/images/image1.jpg', 'assets/images/image2.jpg', 'assets/images/image3.jpg'];
and for example if you want to access your first image, use
AssetImage(imagePaths[0])
I keep a json file inside assets which records the file tree of assets folder.
When file list is needed, I just read from the json file.
Such json file can be easily generated by code.
However, this does not solve your problem directly when u have 5-10k images.
Only one json file might be too large to read.
Images should be grouped and recorded in separated json files.

how can I load images in base64 string by url-loader in typescript + react (rails5 + webpacker)

example repo https://github.com/github0013/typescript_react
I need to load images in base64 string embeded into tag, but importing image files will raise this error.
TS2307: Cannot find module './Octocat.jpg'.
https://github.com/github0013/typescript_react/commit/6670f3ca74404007ad1ed6e4ab0d111f547ee75d
I am still new to typescript, webpack and react, and I am sure I am confused typescript's import and webpack's.
How do I enable url-loader for images? and is this even valid?
https://github.com/github0013/typescript_react/blob/master/config/webpack/environment.js
--
I did try require but it will just return image's path instead of base64 stirng.
// global.d.ts
declare function require(string): string;
solved..
webpacker 3.0.2 already had loaders for image files
https://github.com/rails/webpacker/tree/v3.0.2/package/loaders
https://github.com/rails/webpacker/blob/v3.0.2/package/loaders/file.js
environment.loaders, in rails' config/webpack/environment.js, is just a map, and jpeg png gif are in file loader.
https://github.com/github0013/typescript_react/commit/dc97c3aa9f17bc4f3b0210a426aac27092c5ae7f#diff-41713e6b116dc5cc2bbea556a85db322R3
so overriding file loader's test, then add own image loader will use url-loader for jpeg png gif
https://github.com/github0013/typescript_react/commit/dc97c3aa9f17bc4f3b0210a426aac27092c5ae7f
after adding the loader, regular image require in typescript will return base64 string.

While trying to upload the Image in struts2 the image is not uploading msg Unable to find 'struts.multipart.saveDir'

While trying to upload the Image in struts2 the image is not uploading and showing following msg Unable to find 'struts.multipart.saveDir' property setting. Defaulting to javax.servlet.context.tempdir
You are getting this message due to build din feature of S2.you need to tell S2 file upload interceptor where you want to place the uploaded file using struts.multipart.saveDir property either in the struts.property file or as a constant in struts.xml file like
Struts property file
struts.multipart.saveDir=location of your choice
struts.xml file
<constant name="struts.multipart.saveDir" value="your location" />
If this property is not set it defaults to javax.servlet.context.tempdir.Sine S2 put the upload file in the temp directory in case you have not specified the saveDir but once the process complete, in order for the clean up process it will remove that temp file, so make sure either you have set the saveDir parameter or you should put logic in your action class to pick file from there and move it to your choice location.
For details about S2 file upload read the official doc
handling-file-uploads
This is manual configuration, Once the file uploaded you have to explicitly handle to save the file(due to security reasons server delete the file immediately.)
import org.apache.commons.io.FileUtils;
String fullFileName = "d:/temp/"+uploadFileName;
File destFile = new File(fullFileName);
FileUtils.copyFile(upload, destFile);
Source : FileUpload
You can configure it in struts.properties file
struts.multipart.saveDir - The directory where the uploaded files will be placed. If this property is not set it defaults to javax.servlet.context.tempdir.
put the uploaded files in /tmp. My application will move them to their final destination
struts.multipart.saveDir=/tmp

Resources