In my flutter application I have to download a password-protected zip folder from a remote server and import the .sqlite that is inside in my app.
I'm trying with archive library, but of course I'm open for a better solution if any.
I used the password parameter of ZipDecoder().decodeBytes() method, but it is not working for me.
//inside the `onDone()` callback of an http request
Archive archive = ZipDecoder().decodeBytes(
_myDownloadedData,
password: "mySuperSecretPsw", //here I set the archive psw
);
Uint8List fileDbBytes = Uint8List.fromList(archive.first.content);
setAsWorkingDb(fileDbBytes);
The archive.first.content from the snippet above looks still encrypted. I get the following errors:
E/SQLiteLog(12256): (26) file is encrypted or is not a database
E/DefaultDatabaseErrorHandler(12256): Corruption reported by sqlite on database: /data/user/0/my.own.package/app_flutter/working_data.db
E/DefaultDatabaseErrorHandler(12256): deleting the database file: /data/user/0/my.own.package/app_flutter/working_data.db
You can try
Archive archive = ZipDecoder().decodeBytes(
_myDownloadedData,
verify: true,
password: "mySuperSecretPsw", )
Related
I am unable to delete a file from SVN using SharpSvn.
Here is my code:
using (SvnClient client = new SvnClient())
{
// snip...
string filePath = "C:\\path\\to\\file.txt";
client.Delete(filePath, deleteArgs);
}
Here is the exception:
SharpSvn.SvnInvalidNodeKindException: ''C:\path\to\file.txt' is not a working copy'
I confirmed this filepath exists and is tied to SVN. What is the problem?
This question led me to the answer. I was using the incorrect casing in my filepath. Following the example above, maybe I tried to delete the file "C:\path\to\file.txt" but the actual path on disk was "C:\PATH\TO\file.txt". I fixed by using SvnTools.GetTruePath:
client.Delete(SvnTools.GetTruePath(filePath), deleteArgs);
I have an E2E test to upload a file to the application which works on my local machine but fails to run on Browserstack. But fails with reason :
invalid argument: File not found : /home/travis/build/xx/xx/e2e/src/xx/testfile
Here is the code
let fileToUpload = 'testfile';
let absolutePath = path.resolve(__dirname, fileToUpload);
await browser.setFileDetector(new remote.FileDetector());
let fileElem = $('input[type="file"]');
await fileElem.sendKeys(absolutePath);
I have the files upload in my code base for travis to pick them.
Any inputs are appreciated.
Thanks
Since the file upload is working from your local machine, you can try using the Local File Detector Option.
driver.setFileDetector(new LocalFileDetector());
driver.get("http://www.fileconvoy.com/");
driver.findElement(By.id("upfile_0")).sendKeys("C:\\Users\\hello\\url.txt");
driver.findElement(By.id("readTermsOfUse")).click();
driver.findElement(By.name("form_upload")).submit();
The above code snippet will upload a file located on the local machine. The same details are available here: https://www.browserstack.com/automate/java#enhancements-uploads-downloads
You can port this in the language of your choice.
((RemoteWebDriver) driver).setFileDetector(new LocalFileDetector());
driver.get("https://www.monsterindia.com/seeker/registration");
WebElement browser = driver.findElement(By.xpath("//*[#id=\"file-upload\"]"));
//Upload button xpath
browser.sendKeys("add here upload file path");
System.out.println("File upload Successfully");
This will also simple way to upload file. I have worked this code in Chrome browser.
This code worked for me to run the test in BrowserStack. I'm using Java-selenium-Jenkins-BrowserStack
WebElement uploadFile = driver.findElement(By.xpath("//input[#type='file']"));
((RemoteWebElement)uploadFile).setFileDetector(new LocalFileDetector());
upload_file.sendKeys(System.getProperty("user.dir")+"/src/main/java/resources/common/<Name of your file>.csv");
I use vapor load a html or leaf,it gives me error message '500'.The server log show me
[Data File Error: unable to load file at path /Users/apple/Desktop/QSSwiftServer/Resources/Views/welcome.leaf]
[Identifier: Core.DataFileError.load]
[Possible Causes: file doesn't exist, missing read permissions at specified path, data read is corrupted, system issue]
[Suggested Fixes: ensure that file permissions are correct for specified paths]
[Documentation Links: https://developer.apple.com/reference/foundation/filemanager]
Here is my code:
get { req in
return try self.view.make("welcome.leaf", ["message": "Hello world!"])
}
How can I solve this problem?
You should put your file into {Project Dir}/Resources/Views/
In your case welcome.leaf should be in /Users/apple/Desktop/QSSwiftServer/Resources/Views/
Summary : I am downloading files to chrome app sandbox file system. I have directory called 'downloads' in chrome app's sandbox file system.Following is the code sample
var getSubDirectory = function()
{
subdir.getFile('demo',{create: true},function(fentry)
{
console.log(fentry);
},errohandler)
}
subdir is directory entry. subdir is returning properly, I am getting its output.But when i try to create file into that directory using getFile function, it throws security error.I have permission in manifest for the filesystem.write and filesyste.directory.I tried isWritableEntry() on subdir, its returning false.
I'm using this code to return a FileContentResult with an MSI file for the user to download in my ASP.NET MVC controller:
using (StreamReader reader = new StreamReader(#"c:\WixTest.msi"))
{
Byte[] bytes = Encoding.ASCII.GetBytes(reader.ReadToEnd());
return File(bytes, "text/plain", "download.msi");
}
I can download the file, but when I try to run the installer I get an error message saying:
This installation package could not be
opened. Contact the application vendor
to verify that this is a valid Windows
Installer package.
I know the problem isn't C:\WixTest.msi, because it runs just fine if I use the local copy. I don't think I'm using the wrong MIME type, because I can get something similar with just using File.Copy and returning the copied file via a FilePathResult (without using a StreamReader) that does run properly after download.
I need to use the FileContentResult, however, so that I can delete the copy of the file that I'm making (which I can do once I've loaded it into memory).
I'm thinking I'm invalidating the install package by copying or encoding the file. Is there a way to read an MSI file into memory, and to return it via a FileContentResult without corrupting the install package?
Solution:
using (FileStream stream = new FileStream(#"c:\WixTest.msi", FileMode.Open))
{
BinaryReader reader = new BinaryReader(stream);
Byte[] bytes = reader.ReadBytes(Convert.ToInt32(stream.Length));
return File(bytes, "application/msi", "download.msi");
}
Try using binary encoding and content-type application/msi instead of text/plain - it's not ASCII or text content so you're mangling the file.