right now i am trying to add a feature where the user can download the files uploaded by them through the URL,
I have tried this code sample:
html.AnchorElement anchorElement = new html.AnchorElement(href: "https://www.example.com/file/path/");
anchorElement.download = "https://www.example.com/file/path/";
anchorElement.click();
But it simply opens the file on the browser, which is not what i want, anyone got any other suggestions?
Related
I am getting dynamic link in notification and I want to open dynamic link on notification click.
I am using url_launcher for this purpose but it takes me first to default browser and process the link there and take me back to app.
Is it possible we can process the link inside the app only. I have tried Webview but webview is not opening with dynamic link.
As far as I understand you want to read data from uri link which is generated by firebase in that situation, below code should work :
PendingDynamicLinkData? data =
await FirebaseDynamicLinks.instance.getDynamicLink("Your url here");
String? strLinkData = data.link.toString();
Once you get strLinkData you can move further and do your action.
you can send link like below image
The function getExternalStorageDirectory() and ApplicationDocumentDirectory() gives the same directory to me that is inside the android folder. I like to create a folder in storage/emulated/0 , i tried explicitly creating it with
Directory('storage/emulated/0').create(); then it says you have no permission. And i gave all the possible permissions and still gets the same result. Is there any way to create a folder in storage/emulated/0 ?
NB: _getPermission returns a bool according to the permission status. This code works well in an emulator but it is not working in an actual device.
takePhoto(BuildContext context) async {
if ( await _getPermission(Permission.manageExternalStorage)){
final image =await picker.pickImage(source: ImageSource.camera);
var newPath = "storage/emulated/0/takephotosaver";
var directory = Directory(newPath).create();
File fileIMage = File(image!.path);
var imageName = DateTime.now().toString();
fileIMage.copy("$newPath/$imageName.jpg");
Navigator.push(context, MaterialPageRoute(builder: (context)=>MyPreview(fileIMage)));
}
}
}
Edit :-
This code is working in android version 9 and below but not working in android 10 and 11. Is there a way to display the image taken by my camera in a separate folder?
Things have changed after android 10. You shouldn't create folders in storage/emulated/0 now. Google is strict about that, and your app may get rejected if you publish your app in Google PlayStore. If you still want to do that then add this permission in your AndroidManifest.xml.
<uses-permission android:name="android.permission.MANAGE_EXTERNAL_STORAGE"/>
And to get the permission from the user do this,
if (await Permission.manageExternalStorage.request().isGranted) {...}
Edit:
Whenever you create a new file the device can't automatically find it. You'd have to manually tell the device to refresh for the files. Before you'd have to refresh all the files in the device for it to get updated which was very inefficient, but now you could just send the path of the file that you want to get updated. You can use the media_scanner plugin to do so.
Or If you wanna do it yourself with kotlin then here's the code,
private fun broadcastFileUpdate(path: String){
context.sendBroadcast(Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,Uri.fromFile(File(path))))
}
I want to do the following in C#:
load website in background (google search site)
look into the sourcecode of this site and get a specific link
I tried this before:
Use the WebClient Class to download the String of the website
WebClient client = new WebClient();
string reply = client.DownloadString(url);
client.DownloadFile(gesamter_String, #"C:\neu\localfile.html");
Console.WriteLine(reply);
Use the HTTPClient Class to download the String of the website
string url = hyperlink;
HttpClient client = new HttpClient();
using (HttpResponseMessage response = client.GetAsync(url).Result)
{
using (HttpContent content = response.Content)
{
string result =content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
But the downloaded or displayed sourcecode is very small and doesn't contain the specific link.
However my links works. I have opened the link in foreground with this: System.Diagnostics.Process.Start(url);. This foreground opened site contains the full sourcecode.
Thanks a lot.
First I upload the video in my web server. Then i want to transfer the video to vimeo server.I have downloaded the code from vimeo given github URL (https://github.com/vimeo/vimeo.php). Using composer update the code. After that I am trying to create a custom library for CodeIgniter. In application/libraries folder put all files including 'vimeo.php' for library and in 'autoload.php' page under the 'application/config' folder set $autoload['libraries']=array('vimeo');. Now I call the library from controller
$lib = new Vimeo();
$video_url=base_url().''.$directory.''.$data['video_name'];
$uri = $lib->upload($video_url);
$video_data = $lib->request($uri);
$film_video = $lib->request('/ondemand/pages/myfilm'.$video_data['body']['uri'], array('type' => 'main'), 'PUT');
It shows error. The error is as follows:
An uncaught Exception was encountered
Type: VimeoUploadException
Message: Unable to locate file to upload.
I have checked the video file is present in the '$video_url' path.Could any one help me how to solve this problem.
I have a PDF storred in a Blob
var pdfBlob = new Blob(buffers, {type: 'application/pdf'});
From that I create an Object URL
var pdfURL = URL.createObjectURL(pdfBlob);
That gives something like blob:chrome-extension%3A//mlbdgii.
If I manually copy the URL to a Chrome tab the PDF is successfully opened. However if I try to open it using chrome.app.window.create I just get a "This webpage is not found" error.
So the question is, can I open an Object URL using this method? If not, is there a workaround to get a PDF stored in an ObjectURL to be displayed in a Chrome App or Chrome Tab ?
Check out this: https://stackoverflow.com/a/27256841/3826713 , I had a similar issue and webview was my workaround for it.