Scratch 3.0 taking in a byte array for loading - mit-scratch

I have been working on a project that is implementing Scratch 3.0 for a learning tool for children. We are going to be hosting it on an azure web application. We have hit a bit of a wall though and we aren't really sure how to get past it. The issue that we are having is that we are trying to have a user click on a project that they want to load into the Scratch 3.0 GUI and have a new page open where the user can then play/edit the project. However, Scratch 3.0 does not seem to have a functionality to do that yet. They have a loading feature that allows a file to be directly uploaded from the users computer though.
Is there anyway to change the function so that it would read a project from a byte array that would be sent from another web page?
Thanks in advance for the help!

Related

Unity - Saving an image from a WebGL app to the users machine

I`m building a character creator webGL app and want to enable people to "save" their avatar as a 500x500 PNG file on their desktop.
So far I have been using the exact code from the following source, which works for the Unity Editor:
https://www.reddit.com/r/Unity3D/comments/48hreq/saving_an_image_from_a_webgl_application_to_the/
However, in that topic they never got around to providing a solid answer on how to prompt the user to either download the generated image, or to open the image in a new tab so that they may download it themselves.
I have been testing multiple scripts, but at the end of the day i havent been able to come closer to a solution by myself.
Any pointers, tips or advice would be greatly helpful!

How to get attachment's (NSItemProvider) file path in Swift 'Share App Extension'?

Note: I am very new to Swift programming (2 days only) and I am working on this piece of code as part of an ElectronJS project. So please don't mind my ignorance regarding the basics of the language. Thanks.
I have created a Swift app containing a Share App Extension.
Requirements:
The Share App Extension should be able to send the absolute file path of the shared files to the container app, i.e. If the user selects a file (abc.txt) from Desktop in Finder and Shares to my Application, then the Share App Extension should be able to get the file path as
/users/userName/Desktop/abc.txt
What I am struggling with here is how to get the file path of the files shared with the Share App Extension. What is the way to get file path of the attachments in NSExtensionItem that is available to the Share App Extension or is it available from some other object ?
(I am able to successfully use App Groups to share data between Share App Extension and the Application)
In the final project, the Share App Extension becomes a part of an ElectronJS project as mentioned earlier.
Is there a standard way to share the aforementioned information (file path of the attachments) from the Share App Extension to the main/renderer processes of the Electron application.
I am sharing the solutions below. Please bear in mind that these might not be the best possible solutions and I am open to suggestions.
Solution to Point #1:
Briefing: The user selects files from Finder to be shared via the Share App Extension of the application which is registered with the OS if the extension context of the selection matches to that of the Share App Extension. Upon doing so, the Share App Extension receives the extension context alongwith NSExtensionItem. The NSExtensionItem object contains the NSItemProvider object which is the object you'd get for all the files (attachments) shared via the Share App Extension.
Now, for each item type that you receive via the Share App Extension, after looking for the data that your function recognizes via hasItemConforminToTypeIdentifier(_:), you can use UTI (Uniform Type Identifier) to identify its data.
Remedy: Here, the crucial part is to understand that one should be treating their input files as firstly being of the type: kUTTypeURL. Then, in the completionHandler for the loadItem method of the NSItemProvider object one would get NSURL which is basically the file path I was looking for.
Solution to Point #2:
Briefing: The Share App Extension has the luxury of being written in Swift but the main app in our project does not ! The main application is written in ElectronJS which is far far far far from being integratable with Swift ! Except for the fact that the application written in ElectronJS has the ability to be packaged in the form of a dmg application, there is very little integratability between ElectronJS and Swift as far as the language and framework intertwining is concerned.
Premise:
So, the premise is to be able to share the filepaths extracted earlier to be passed from the Share App Extension (written in Swift) to the main application (written in ElectronJS). Now, if the main application was a Cocoa application, things would have been much easier. If both of them belong to the same App group, then using the Swift APIs they could have read/written synchronously to the Shared Memory. However, the problem arises as those APIs are not available in ElectronJS. One remedy can be to run the Swift code in a sandboxed environment within the ElectronJS application using nodeJS libraries. However, a sandboxed environment presents its own nuances in data sharing. So, I have kept this approach on hold for now.
So, the approach that I have chosen right now is to use App Data Directory to share this intermediary information. The Share App Extension would be writing the filepath information in the App Data directory of the application and the ElectronJS application would use nodeJs APIs to access this information. Keep in mind that this is a very primitive approach and requires menial efforts but the requirements for this particular case doesn't need stringent security measures anyhow.
However, I am positively looking for a better way to solve Problem #2.

Unity3D file explorer on Microsoft Hololens?

My goal is to read a XLSX file and use this to generate objects in Unity3D. However this app is for a hololens. It is possible to let the game ask the user to select a file which it should import (at runtime)? like how a regular windows forms app opens an explorer window and lets you browse for a file.
so, just to clarify, what i DONT want is to import the XLSX file as an asset before building the app (because the game shouldn't be limited to just use that file!).
Let me know if the question isn't detailed enough, I'll try to specify it more if needed.
Unity itself doesn't have any way to implement a filebrowser on runtime however people have made their own versions of a filebrowser which you could use. Something like the ImprovedFileBrowser by Daniel Brauer. Which was inspired by a Filebrowser made by AngryAnt
Note: The ImprovedFileBrowser uses the ImprovedSelectionList which you will also need to get it to work.

Unable to view Database with Sqlite plugin Phonegap - no file extension

I am using phonegap to create an app and am unable to view the database with the sql lite plugin (http://www.tylerfrankenstein.com/user/4/browse-android-emulator-sqlite-database-eclipse). Unfortunately, even though I can find the database that my app has created, for some reason labelled as 1 I cannot use the viewer. I can use the viewer on the Databases.db file. Looks like the problem is that it doesn't have the db extension?? Why can't I view the DB from within Eclipse? Driving me crazy, any help would be greatly appreciated.
The app is successfully creating a database, storing and pulling information out of it so I know it is working correctly, I just need to be able to view it to develop further more easily.
Here's what it looks like in Eclipse, note that the sql lite button is greyed out and the file is just 1 instead of 1.db as I would expect. I can't find anyone else experiencing the same problem...

Which is the best method to get a local file URI and save it online?

I'm working on a web project but the scenario has some restrictions for a specific user case. We have been investigating a web-only solution and a dropbox-like native way to solve this.
The main restriction is that we shouldn't upload local files to a cloud. We can only track local URI's.
The use cases are:
As a developer, I should be able to link the URI of a local file to a webapp. Thus, I can click on a webapp element and the local file should be opened.
As a user, I should be able to add a directory and view the same structure on the webapp (clicking opens the file). The files are not uploaded.
Possible solutions:
We started trying the FileSystem API but when the specs. were fully defined, we figured out that a local sandbox was not enough, and we can't access to the local URI due to security issues.
We are considering a Dropbox-like native app. The Invision Sync App is closer to what we want.
The less optimal solution would be a complete native application.
The question:
Which is the more efficient way to achieve this? Any idea on some native libraries for doing this faster? Any web-only workaround?
Thanks in advance.