Comments (15)
In browser.
from image-to-base64.
I think that on any error should be run the .catch branch.
from image-to-base64.
Thanks a lot by tell-me.
Can you explain as simulate this error?
I guess that was a problem of us document README
, right?
see ya
from image-to-base64.
If server return 404 - I am expecting an error, not complete. I.e. .catch, not .then:
imageToBase64("file_not_exist.png")
.then(
(response) => {
console.log(response); // PCFET0NUWVBF... - base64 of server 404 response
}
)
.catch( // no fired!
(error) => {
console.log('Error: '+error); //Exepection error....
}
)
from image-to-base64.
Okay, but you using in NodeJS or browser?
from image-to-base64.
ok, in browser you must setting the path, example:
imageToBase64("./file_not_exist.png").then(console.log).catch(console.log);
OR
imageToBase64("https://yourdomain.com/images/JavaScript-logo.png").then(console.log).catch(console.log);
In browser you always using URL.
Do you understood?
see ya.
from image-to-base64.
Sorry for delay.
Ok, if file name begin from "http..." then the .catch are fired on 404. If not (even if the path present) - the .catch not fired on 404. Is it ok?
from image-to-base64.
No problem, please send to me one example, is important I comment for you: "This lib just accept https
not using http
", ok?
This case on web (run in browser)
from image-to-base64.
<!DOCTYPE html >
<html lang="ru">
<head>
<LINK href="common.css" rel="stylesheet" type="text/css">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<META http-equiv="Content-Script-Type" content="text/javascript">
<title>This is a example of image-to-base64</title>
<script src="image-to-base64.min.js"></script>
</head>
<body>
<h1>Hello!</h1>
<p>
<img id='image1' src='test/nodejs.png'>
<img id='image2' src='http://mediatheque.rsl.ru/image-to-base64/test/nodejs.png'>
<script>
imageToBase64("http://mediatheque.rsl.ru/image-to-base64/test/nodejs.png")
.then(
(response) => {
alert('1. This is responce ok. Result are '+response.length+'bytes length.');
}
)
.catch(
(error) => {
alert('1. Error');
}
)
imageToBase64("/image-to-base64/test/nodejs.png")
.then(
(response) => {
alert('2. This is responce ok too. Result are '+response.length+'bytes length.');
}
)
.catch(
(error) => {
alert('2. Error');
}
)
imageToBase64("test/nodejs.png")
.then(
(response) => {
alert('3. And this responce ok. Result are '+response.length+'bytes length.');
}
)
.catch(
(error) => {
alert('3. Error');
}
)
imageToBase64("http://mediatheque.rsl.ru/nodejs.png")
.then(
(response) => {
alert('4. This request return 404, but .catch not fired and responce length '+response.length+'bytes.');
}
)
.catch(
(error) => {
alert('4. Error');
}
)
imageToBase64("mediatheque.rsl.ru/nodejs.png")
.then(
(response) => {
alert('5. This request return 404, but .catch not fired and responce length '+response.length+'bytes.');
}
)
.catch(
(error) => {
alert('5. Error');
}
)
imageToBase64("/test/nodejs.png")
.then(
(response) => {
alert('6. And this request return 404, and .catch not fired and responce length '+response.length+'bytes.');
}
)
.catch(
(error) => {
alert('6. Error');
}
)
</script>
</body>
</html>```
from image-to-base64.
I tried access yours images and don't possible. So, this probably is a error in your server.
This can be a problem of path or url.
You can testing as example below:
imageToBase64("http://mediatheque.rsl.ru/image-to-base64/test/nodejs.png")
.then(
(response) => {
alert('2. This is responce ok too. Result are '+response.length+'bytes length.');
}
)
.catch(
(error) => {
alert('2. Error');
}
)
from image-to-base64.
Sorry, I don't understand.
The right image url is: "http://mediatheque.rsl.ru/image-to-base64/test/nodejs.png"
The "http://mediatheque.rsl.ru/test/nodejs.png" - is a sample a bad url, this produce 404 server response.
By link above You can see code in action, and see alert number and message. Messages appear not in the order of numbers, of course.
from image-to-base64.
No problem, my English is very bad.
Well,
This error occurs because this route (URL) that you try access don't exists in your application.
Your images they are inside path image-to-base64
, understood?
I realized that you this using my images of example, do you need on your application put on all images and execute code with path.
from image-to-base64.
Yes. My case is generate the image file name, and retrieve file by this name. If file exist - display img, if not - do something. I want only one request to server for it.
On this case I do not have way to check "File not exist" situation.
from image-to-base64.
Nice, always that don't found file the lib will return a base64. We go improvement the treatment this errors, what do you think?
from image-to-base64.
Nice, I will create a issue with this treatments for be implemented. For as soon possible to be make.
from image-to-base64.
Related Issues (20)
- Invalid base 64 string [Help Wanted] HOT 1
- one typo in README.md HOT 3
- is there way I can run it synchronously? HOT 5
- Error message not meaningful HOT 3
- Cors-Policy Error HOT 1
- Typescript support HOT 5
- how to solve ERR_UNESCAPED_CHARACTERS error? HOT 6
- Create a new release and publish on NPM HOT 1
- e.buffer is not a function HOT 9
- How to return the Base64 from object imageToBase64 HOT 1
- statSync issue due to too large image size HOT 9
- don't have time to take care of him, Can someone take care of it? HOT 3
- invalid regular expression in safari HOT 6
- Cannot find module 'fs' in 'image-to-base64' HOT 4
- CORS error when using imageToBase64 HOT 1
- Cannot find module 'fs' in 'image-to-base64' HOT 1
- Invalid regular expression: invalid group specifier name HOT 2
- Base64 image converter is not valid HOT 5
- CORS policy: No 'Access-Control-Allow-Origin' in react js HOT 1
- Blank Page in Safari : Create React APP project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from image-to-base64.