im trying to look inside an epub file in react native expo.
nothing i did works.
tried JSZip, which said 'Can't find end of central directory '
tried 'react-native-zip-archive' which didnt work.
tried to change file name also to zip , and then extract , but didnt help.
JSZip.loadAsync(targetPath).then(function (zip) {
Object.keys(zip.files).forEach(function (filename) {
zip.files[filename].async('string').then(function (fileData) {
console.log(fileData) // These are your file contents
})
})
})
any ideas ?
Related
} else if (msg.content === '?_saifz test') {
const attachment = new Discord.Attachment('https://th.bing.com/th/id/OIP.CK95Aog4xZCaWVHnAr61pwHaHa?w=183&h=183&c=7&o=5&dpr=1.25&pid=1.7') // the problem
msg.channel.send(attachment)
}
})
keepAlive()
client.login(process.env.lolUCannotGetToken)
I didn't put the other command because they work.
That is not a valid image file type. You'll need to find a link to an image with a valid extension such as .jpg, .png or .jpeg.
Also, in order to prevent issues with the site taking the image down from their servers, I suggest you download the image to your project, so it's there forever.
I am trying to upload a file by using sendKeys method and adding absolute path to file but the file does not get uploaded. I think sendKeys method doesn't work very well on react pages. Can someone please help and give a workaround of this problem? Below is the code snippet:
I do not see any error but the file doesn't get uploaded.
Below is the function I am using to upload file:
importFileButton: {
get: function() {
return this.findElement(this.by.xpath("//div[#id='upload-file']//button[#aria-label='Import file Browse ']"))
}
}
attachCommaFile: {
get: function () {
browser.setFileDetector(new remote.FileDetector());
var fileToUpload = './../../files/fileimport_Pipe.txt',
absolutePath = path.resolve(__dirname, fileToUpload);
return this.importFileButton.sendKeys(absolutePath);
}
}
file uploads work with input tags
You're trying to sendKeys to a wrong element - button
Most like the tag you're looking for will have the following css [type=file]
for more detailed info see this post https://stackoverflow.com/a/66110941/9150146
I have a react environment where I am uploading files in small chunks to s3. Now I am supposed to upload zips as well but in unzipped state from the browser itself.After much findings I worked out the following,
jsZip.loadAsync(zipFileAsBuffer).then(function (zip) {
Object.keys(zip.files).forEach(function (filename) {
console.log(filename)
zip.files[filename].async('string').then(function (fileData) {
})
})
})
Later when I do fileData.byteLength for chunking it gives an error saying cannot find byteLength of undefined.I assume this is because the process I am using requires buffer but instead I get blob from jsZip. How can I convert blob to buffer or if some better approach is required then please do tell.
The only change that I needed to make in the existing code was to use "ArrayBuffer" instead of "string".So the modification looks like,
jsZip.loadAsync(zipFileAsBuffer).then(function (zip) {
Object.keys(zip.files).forEach(function (filename) {
console.log(filename)
zip.files[filename].async('ArrayBuffer').then(function (fileData) {
})
})
})
I was trying to load image from local resource whose format is .JPG. But every time it gives me following error.
Do react native support .JPG format ? Can anyone help me on this ? Thanks...
If you are sure that your image_path is right then you could rename the Image in your folder from the capital letters (.JPG) to lower case letters (.jpg).
Tested this case for Windows and could reproduce and fix it with the above solution.
react-native version: 0.23.1
For clarification:
var yourPicture = require('./yourPathToYourPicture/picture.jpg); //Working
var yourPicture = require('./yourPathToYourPicture/picture.JPG); //Not-Working
Solution to solve the capital letter problem: Save your picture in your project folder with lower case letters yourPicture.JPG -> yourPicture.jpg
Use your image
render(){
return(
<Image source={yourPicture}/>
);
}
You must use Image from react-native
import {
Image,
} from 'react-native';
...
Image have a prop called source
<Image source={require('./img/fotofondo_app.jpg')}/>
If the error still, try to execute react-native run-android beacuse the image files aren't read in hot.
So I'm using Cordova + Sencha Touch for an app and Antair's SQLitePlugin (https://github.com/Antair/Cordova-SQLitePlugin) to import and use an SQLite database in it.
I managed to import my (kinda big) prepopulated database using Antair's importPrepopulatedDatabase ( window.sqlitePlugin.importPrepopulatedDatabase({file:"mydb.db",importIfExists:false}) ) method and it works just fine. The thing is I noticed the app is using twice the size it really needs as it keeps the file after importing it.
I checked and the app works just fine if I delete the file from /cordova/www/db and build again, it keeps the actual db in the app's filesystem I guess, but I can't find a way to programmatically delete that file after it has been imported.
I looked around and found cordova file plugin (https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md), but from what I saw from the docs it only grants read permissions on the www folder, so that won't do it.
Does anyone have any workaround for this? I could really use that extra space.
By using cordova file plugin api you can do this,
please refer this :
deleteFile: function(fileName) {
var that = this;
if (!fileName) {
console.error("No fileName specified. File could not be deleted.");
return false;
}
window.requestFileSystem(LocalFileSystem.TEMPORARY, 0, function(fileSystem){ // this returns the tmp folder
// File found
fileSystem.root.getFile(fileName, {create: false}, function(fileEntry){
fileEntry.remove(function(success){
console.log(success);
}, function(error){
console.error("deletion failed: " + error);
});
}, that.get('fail'));
}, this.get('fail'));
}