flutter web on s3 static hosting not able to display images - flutter

When I do a
flutter web build
and created a static website on s3, the flutter app tries to access images via /assets but the build puts them inside 2 nested assets folders
build
web
assets
assets
github.png
other images
I put a sample build on github where the assets are
https://github.com/matthewchung74/test/tree/main/assets
and the build assets are here
https://github.com/matthewchung74/test/tree/main/build/web/assets/assets
I'm not sure if this is a bug or if I am just doing something wrong.

When using , , or , the browser automatically blocks access to pixels when it knows that an image is coming from another site and the CORS policy disallows access to data.
WebGL requires access to the image data in order to be able to render the image. Therefore, images to be rendered using WebGL must only come from servers that have a CORS policy configured to work with the domain that serves your application.
For more information:
Displaying images on the web

Related

how to bundle flutter desktop assets into a single file for production build

after building the flutter project for desktop, flutter copies all asset files inside the assets directory into the build/flutter_assets/assets which are easily accessible and modifiable (which is not secure at all!), user can change the whole images easily and do some kind of modding the app with no experience required! or even in the worst situation with modifying the AssetManifest he could change the runtime dynamic libs with the malicious libs and get a hook from the app.
most modern frameworks/languages have the option to embed the resources inside a single file (that makes it harder to modify the files / repack the resource file) for example C#(WPF/Win32) embeds the resources in the resource Resource section or even Electron (Javascript) embed the whole resources into a file (it's easy but better than nothing)
I didn't find any similar behavior in Flutter Desktop (Windows/Mac/Linux) is there any alternative for flutter?
For now [12/12/22] it seems flutter desktop won't use resources to bundle the resources into a single file.
So I've created two separate libraries to achieve this
https://github.com/kooroshh/bundler that compresses the whole given assets into a single file and encrypts it with AES-128
https://github.com/kooroshh/flutter_bundler that reads the bundle file from and decrypts it into the memory that can be used with Image.memory or Direct file access using Virtual Files.
I hope an official solution gets implemented in the flutter framework.

Can't load an Adobe Captivate HTML5 presentation in a Google Cloud Storage bucket

I am trying to store an Adobe Captivate HTML5 file in a bucket and then load the file and play the presentation. I've watched other videos on this and many people have successfully used Google Cloud Storage for this purpose, but they generally use it on a public bucket. My bucket is private and only accessible to a couple of users if it matters.
The file I'm trying to load will only go as far as showing a loading icon. Originally it only showed a blank page, and I was advised to add a tag to the with the "Authenticated URL" of the file and now it shows a loading icon but still won't load correctly.
Has anyone had this issue with html5 files before? Or know if there is anything in particular you need to do differently to view a file like this on a private bucket with a couple users vs allUsers?
Adobe Captivate HTML5 file, is still HTML codes. After you uploaded to the GCS, when you visit GCS bucket, actually you executed getobject, you downloaded the file to your browser, of course, the browser can write HTML file and display in your browser. Just set it to public to allusers, clean the browser cache. the try to use the public url visit again.

IONIC 4: How to call iOs file resource from custom script within app

Here is the situation:
Ionic 4: (cli-5.2.7)
XCode 10.3
We have a custom eReader that lives in our assets folder.
When we want to download an eBook from our server and read it, we download the file and save it using the Native File plugin.
When we start up the reader, we send it the container in which we want the reader to be created and built, and an internal url to the file resource we want to read.
After window.Ionic.WebView.convertFileSrc, the file ref looks like:
ionic://localhost/_app_file_/var/mobile/Containers/Data/Application/[APP-ID]/Library/NoCloud/[BOOK-ID]/vol-001-chapter-006.xhtml
The reader will then build the iframe and send a simple XMHttpRequest to the provided url, then place the resulting html into the iframe.
The problem is that it only works on first load of the eBook from our server
I can see the file being downloaded, and written to its own folder in the apps file system (File.dataDirectory).
When I debug the XMLHttpRequest in our eReader.js, I can see the call being made to the resource and the HTML returning to the request, which is then rendered on the page.
BUT, if I close the app, reopen it, and try to access the already-downloaded book, the XMLHttpRequest in our eReader.js returns nothing.
I can verify that the file exists at the resource location after a reload, but the XMLHttpRequest acts like it cannot find anything at the provided location.
AND, this is only on iOs. Android works as intended.
My questions is, what am I missing? Is this something to do with the iOs permissions or persistence?
Any help would be appreciated.

Multi-page Airconsole controller?

I'm just starting to create a controller for use with Airconsole. I'd like it to be somewhat complicated and will be using Angular to create different pages.
In Unity, I can drag in a controller.html file. However, I've been getting resource not found errors when I try to access say controller.js or controller.css. How can I upload multliple files to the Airconsole host? Is there a general pattern used by other games?
So far I'm considering
hosting my app separately and just redirecting to my separate web page. This seems to give errors in the emulator though.
Compiling the entire app into just one HTML file.. Not sure how to get these entirely into one file. When I run ng build I get a smaller dist compiled file, but it still consists of several smaller files. Will try dragging that into Unity and trying again. But dragging the entire Angular project inside Unity felt like a really bad idea..
Link to files hosted on separate pages but still have the uploaded HTML file do something.. But not sure how much I need to do here vs how much I can move to other files that I host.
You can create your controller using controller.html with Angular (1?!), have different pages (e.g. via ng-include and the angular routing module) and upload everything to AirConsole (developers).
By using ng-include you can have multiple .html views you dynamically load into the controller.html.
I once wrote an example app for AirConsole and Angular:
https://github.com/francois-n-dream/airconsole-angular-phaser
Just think of it as if you would make a (mobile) website which in addition uses the AirConsole API for device communication.
My basic "how to include other files" question was answered well by another question: How to include js and css.
For the more generic question of working with Angular, I still haven't quite figured it out. But what I'm doing at the moment:
I have an Angular project outside of Unity. I run ng build to compile everything into a folder dist. Then two options work:
Deploy the dist folder to static file hosting and change index.html's relative links to point to the separately hosted files with <base href="https://cloudfilehosting/airconsole-host/">
OR
Copy the dist folder into Unity's Assets/WebGLTemplates/AirConsole folder.

MCImage Manager handling 2 websites with common folder

My Requirements
Implement MCImageManager so that users can upload images to a
"centralized" folder
Allow users to select an imagae on the centralized "ImageLibrary" and place it on a web page or blog post
IMPORTANT:
There's one challange that I need to find a solution for. Typically images are placed in a folder that exists in the website e.g. ~/Images or ~/Content/Images
The challange we have is that I will be having, however web pages will be displayed through separate websites. More specifically, in a typical scenario, a user would upload an image through MCIMageManager that places the file in a folder in the web application. So the image may be uploaded to a folder like D:\xyz\ImageLibrary.
However, the root folder may be F:\ on an entirely different server.
Therefore we need to come up with a way to share image folders between two websites so that regardless of where the image folder may be, the image will display correctly both on xyz web site management module AND the actual website.
Regards
Abhishek
For this use case you should mount the upload directory of server A to the upload directory of server B.