provide file path to project.load?
I'd like users to be able to open our application straight to a project file of theirs. Is it possible to dynamically provide the file path for the file.json to use instead of them having to pick it with the file picker each time? Like if I could provide “C:\Users\username\Desktop\test.json” to either system.read-file or project.load.
-
No, that is a limitation of how browsers work in general: A website cannot load a local file from the user's system without manual intervention. If that was allowed, a malicious website could, for instance, access C:\Data\MyPasswordlist.txt !
What you could do instead, is to write two workflows for saving and loading projects, using project.create and app.load-project respectively. These projects can then be stored as a blob in a featureservice, in a database, or even on the server's filesystem (if you are using on-premise)
1 -
I wouldn't mind hosting it for them on our server. Are you saying it is possible to bypass the file picker and pass it in directly if it is on the server? We do have on-prem studio products.
0 -
Yes, you would have a startup workflow that retrieves a project from wherever it is stored, and then calls app.load-project
0 -
app.load-project is deprecated, so I'm trying to use project.load. I'm able to spit out the JSON in an alert in my app from a project file on the server, but it's failing to load as a project. The arguments for this command are:
Any of:
AppConfig,Blob,SharedProject,Blob[],HasAppConfigDo you know how to convert the JSON to one of these?
Though I'm not sure if that's the actual problem… the error is saying: "The following error occurred while retrieving item "c45c70fc-064c-41c2-a96c-0eb38124d6b5" of type "layer-extension" from an App: No item of type layer-extension is defined with ID 'c45c70fc-064c-41c2-a96c-0eb38124d6b5'." even though the .json loads fine when I do it manually in the app so there shouldn't be any missing components.
Update: Ha! I got it. Had to put a Create File on the client side and then pass that to the project.load.
Thanks for the idea of getting the file from on the server!
2 -
Berend Veldkamp Now we know where you keep your passwords. :)
2 -
Glad you found success here, Chelsea Rozek. And Berend, better move those passwords! I suggest under the mattress.
As an aside, this pattern of storing a project definition blob somewhere that the user does not have to think about is what generally led to the Shared Storage Service and Shared Saved Projects functionality in VSW.
0 -
@... Thanks for the links. This is a one off for a particular user so I'm happy with the workflow checking if she's logged in and then loading her particular project from our server without having to set up a separate data store.
Hijacking my own thread, is it possible to have Save Project use a Save As dialog so they can overwrite an existing .json? One of my users is amassing many copies of project files because it downloads automatically with the file name you type in.
1 -
@... Thanks for the tip! I just printed out all my passwords and stashed them under the bed. That said, my password file safely contains the passwords in reverse, so I think I'm good anyway.
0 -
I am glad you are sleeping well on a bed of passwords, Berend Veldkamp .
Chelsea Rozek good question. I did some fiddling around with the project.create and system.download-file and was not able to find an immediate solution to this in VSW command chain syntax. I suspect the only/best way to implement logic with a specific preset file path would be to handle this via Workflow.
0
Please sign in to leave a comment.
Comments
9 comments