Error: Unable to resolve image URL from source ({"_key":"9a9f9af92a31","_type":"image"}) - sanity

I have a website based on Sanity.io and the following error message:
Error: Unable to resolve image URL from source ({"_key":"9a9f9af92a31","_type":"image"})
Code:
components\PortableTextComponents.tsx (17:50) # image
image: ({value}) => {
const builder = imageUrlBuilder(client);
return <img src={builder.image(value).url()} />;
^
}
}
}

Related

expo-share getting error while sharing hyperlink (deeplink)

i am trying to share link using expo-sharing, it works sharing file and hyperlink but gives me error on sharing like with custom "scheme", that is link like deeplink eg:
"myapp://detail/cjhqNmpzbDB5aWE/car"
<TouchableOpacity
onPress={async () => {
const isSharable = await Sharing.isAvailableAsync();
if (isSharable) {
await Sharing.shareAsync(
"ekaa://detail/cjhqNmpzbDB5aWExOXZscg==/Luxurious Wooden"
);
}
}}
>
<Text>Share</Text>
</TouchableOpacity>
getting error on line:
await Sharing.shareAsync(
"ekaa://detail/cjhqNmpzbDB5aWExOXZscg==/Luxurious Wooden"
);
error:
Possible Unhandled Promise Rejection (id: 11):
Error: You don't have access to provided file.
promiseMethodWrapper#http://192.168.1.78:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:2485:45
#http://192.168.1.78:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:93192:46
#http://192.168.1.78:19000/node_modules/expo/AppEntry.bundle?platform=ios&dev=true&hot=false:222066:51
generatorResume#[native code]

Error when moving file with react-native-fs, file already exist

I am trying to move an image to the library using react-native-fs in iOS
const originalPath = "/private/var/mobile/Containers/Data/Application/7EB7B0CB-FCA8-49EE-843A-04BBB0B286B1/tmp/ReactNative/E70143FD-21A8-42AA-BFD2-A8FA45D7D93A.png"
const destinationPath = RNFS.LibraryDirectoryPath + "/kj3.jpg";
RNFS.moveFile(screenShotPath, destinationPath).then((data) => {
console.log(data)
}).catch((err) => {
throw err
})
The destination path in this case is
/var/mobile/Containers/Data/Application/7EB7B0CB-FCA8-49EE-843A-04BBB0B286B1/Library/kj3.jpg
I get an error
Error: “E70143FD-21A8-42AA-BFD2-A8FA45D7D93A.png” couldn’t be moved to “Library” because an item with the same name already exists.
I also get the same error when I try to copy the file.

AssertionError [ERR_ASSERTION]: Cannot wrap non-Error object

When i try to upload Image using strapi on cloudinary then it says internal server error on strapi backend and gives me this error AssertionError [ERR_ASSERTION]: Cannot wrap non-Error object in terminal. I don't know what is the problem, Help me to resolve this issue thanx
Step 1: Create a directory path './config/plugins.js' from the root of your Strapi application
Copy and paste the code below in your plugins.js file and change the details of the providerOptions object.
// ./config/plugins.js
if (process.env.NODE_ENV === "production") {
module.exports = ({ env }) => ({
// ...
upload: {
provider: "cloudinary",
providerOptions: {
cloud_name: env("process.env.CLOUDINARY_NAME"),
api_key: env("process.env.CLOUDINARY_KEY"),
api_secret: env("process.env.CLOUDINARY_SECRET"),
},
},
// ...
});
} else {
module.exports = {};
}
Step 2: Create a .env file at the root of your Strapi application. Copy your api secret, api key and api environment variable from your cloudinary dashboard and save in the .env file.
CLOUDINARY_URL=cloudinary://CLOUDINARY_API_KEY:CLOUDINARY_API_KEY#CLOUDINARY_NAME
CLOUDINARY_NAME=CLOUDINARY_NAME
CLOUDINARY_API_KEY=CLOUDINARY_API_KEY
CLOUDINARY_API_KEY=CLOUDINARY_API_KEY
This worked for me. I hope it should work for you too.

Take screenshot for specific element for ios devices - safari browser

i'm trying to take a screenshot for any specific element on the safari browser - by appium+webdriverio+browserStack.
appium version : 1.15.0
here are the error logs :
Calling AppiumDriver.getElementScreenshot() with args: ["5028","e154c6f0-73b9-4306-b661-d3206aa7ba8e"]
[debug] [XCUITest] Executing command 'getElementScreenshot'
[debug] [RemoteDebugger] Executing atom 'getElementScreenshot'
[debug] [MJSONWP (e154c6f0)] Encountered internal error running command: Error: Unable to load Atom 'getElementScreenshot' from file '/usr/local/.browserstack/appium_1.14.0_bstack/node_modules/appium-remote-debugger/atoms/getElementScreenshot.js'
[debug] [MJSONWP (e154c6f0)] at getAtoms (/usr/local/.browserstack/appium_1.14.0_bstack/node_modules/appium-remote-debugger/lib/atoms.js:17:13)
2019-11-21 06:44:37:879 - [HTTP] <-- GET
Please help, is there anything I'm doing wrong? Please suggest as i want to take a screenshot of specific webElement by appium on safari browser
Afaik there is currently no way of taking a screenshot of a specific web element (via web selectors) with only webdriverio and appium. While webdriverio provides an element.saveScreenshot function, it does not seem to work on mobile with appium.
The way that I work around it is to take a screenshot of the whole page with browser.saveScreenshot(filepath) (make sure to switch to native context for this) and then crop it to the elements rect with an image library (sharp, in my case).
My util functions look like this:
import fs from 'fs';
import path from 'path';
import sharp from 'sharp';
export function takeScreenshot(element) {
const timestamp = moment().format('YYYYMMDD-HHmmss.SSS');
if (fs.existsSync('reports/screenshots/')) {
const filePath = path.join('reports/screenshots/', timestamp + '.png');
WebView.switchToContext(CONTEXT_REF.NATIVE);
browser.saveScreenshot(filePath);
WebView.switchToContext(CONTEXT_REF.WEBVIEW);
if (element) {
const size = getRealSize(element);
const location = getRealLocation(element);
const outputPath = path.join('reports/screenshots/', element.selector + timestamp + '.png');
sharp(filePath).extract({ width: size.width, height: size.height, left: location.x, top: location.y }).toFile(outputPath)
.then(function () {
fs.unlinkSync(filePath);
fs.renameSync(outputPath, filePath);
})
.catch(function (err) {
console.log(err);
});
}
}
}
export function getPixelRatio() {
return browser.capabilities.pixelRatio ? browser.capabilities.pixelRatio : 1;
}
export function getRealLocation(element) {
const location = element.getLocation();
return {
x: Math.round(location.x * getPixelRatio()),
y: Math.round(location.y * getPixelRatio())
}
}
export function getRealSize(element) {
const size = element.getSize();
return {
width: Math.round(size.width * getPixelRatio()),
height: Math.round(size.height * getPixelRatio())
}
}

Jest snapshots for react native static images throwing warnings

I am trying to write snapshots tests to check if the correct image is being returned. When I just use zero transforms than the result is always '1' which isnt very helpful. I went onto the site and added this to my package.json
"transform": {
"\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$": "<rootDir>/jest/fileTransformer.js"
}
and create a file called fileTransformer that looks like this
// fileTransformer.js
const path = require('path');
module.exports = {
process(src, filename, config, options) {
return 'module.exports = ' + JSON.stringify(path.basename(filename)) + ';';
},
};
Now the tests are resulting in useful snapshots which is great, however im not getting warnings in my console that look like this
console.error node_modules/prop-types/checkPropTypes.js:20
Warning: Failed prop type: Invalid prop `source` supplied to `Image`.
in Image
You can take a look at moduleNameMapper configuration
"^[./a-zA-Z0-9$_-]+\\.png$": "<rootDir>/RelativeImageStub.js",
and inside the file you can export a dummy image path
RelativeImageStub.js
export default '/dummy/path/to/dummyImage.png';
You should also be able to mock the result from importing the image:
Component.spec.js
import Component from './Component';
jest.mock('./path/to/the/image.png', () => "dummy/path/image.png");
Component.js
import image from './path/to/the/image.png';
export default function Component() {
return <Image source={image} />;
}
This way you'll also get an error if the specified path does not exists.