Runtime xml/json generation of directory content - objective-c

For an ios app I try to develop, I need to get a listing of the content of an online directory. (My app works with local directories but I'm trying to edit it so it works with an online directory)
I've been looking into this a lot but I can't manage to find the best solution to do this. (I learned you can't read the contents of an online directory and subdirectories with objective-c and print them to an array to display them in, for example, a tableview).
I did learn how to create a connection and output the html of a certain page (or an xml file). That's why I was wondering... Is there a way (webservice?) to generate an xml/JSON/html file that prints the content of a directory (if possible also subdirectories)? The generation of this xml/JSON/html has to be done at runtime, the moment my app asks for the file, since people will be able to add files (pdf's, video's,...) to the directory via FTP. (editing the xml/JSON file everytime is not an option).
Any help would be very much appreciated.

You could create a simple webservice in many ways. For example, with PHP you could write something like this:
<?php
$dir = '/myDir';
$files = scandir($dir);
echo json_encode($files);
?>
Then just point your app to get the contents of that page and parse the JSON.
scandir: http://php.net/manual/en/function.scandir.php
json_encode: http://php.net/manual/en/function.json-encode.php

Related

yt-dlp : How can I have separate file format for playlists and single videos

I have an urls file where I store all links I want to download. I download from it using yt-dlp -a urls.
For playlists I'd like to put videos into a folder, like it's shown in documentation examples, while for single videos I'd like to keep the separate file format though.
How can I do it with a single configuration file? If it's not possible with a single configuration file, I'd want to have other options in a single common place.
Note: In documentation I saw TYPES: in --output, but I don't know how to use it and if it's applicable to my case.
PS: If it's possible to write a wrapper using yt-dlp as a library, with a hook, it'd be a viable options

In ASP.NET Core MVC, how do you make uploaded images accessible to logged users in app but not to general public?

I have image upload in my system. I am struggling to understand what is the logic of serving images.
If I upload directly to wwwroot, the files will be accessible to everyone, which is not what I want.
I understand I could save the file contents in the database as base64 but those can be big files, and I would like them on the server in files.
I could convert them on the fly when requested. Most probably getting the path to file, then loading it in a memory stream and spitting out the base64. But seems overkill, and not an elegant solution. I use Automapper for most data and I have to write some crazy custom mappers, which I will If there is no other way.
I could create virtual path, which from what I understand maps physical path on server to a url which doesn't seem any different than option 1
I fancy there is a way to spit out a link/url that this user has access to (or at least logged users) that can be passed to the app so it can load it. Is this impossible or unreasonable? Or am I missing something?
What is the correct way of doing in general?
Also, what is a quick way to do it without spending days for setup?
To protect the specific static files, you can try the solutions explained in this official doc.
Solution A: Store static files you want to authorize outside of wwwroot, and call UseStaticFiles to specify a path and other StaticFileOptions after calling UseAuthorization, then set the fallback authorization policy.
Solution B: Store static files you want to authorize outside of wwwroot, and serve it via a controller action method to which authorization is applied and return a FileResult object.

TYPO3 CMS 9.5.5 most simple extension

I have to create a simple TYPO3 extension for version 9.5.5.
i installed TYPO3 CMS 9.5.5 from https://bitnami.com/stack/typo3
in docu for latest (9-dev)
https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/FilesAndLocations/Index.html
they say "usually located in typo3conf/ext for local extensions, or typo3/sysext for system extensions."
i dont have a "typo3conf/ext", no "typo3conf" and "typo3/ext" . and yes there is a "typo3/sysext".
I have not found a guide online that takes this fact into account.
Then i read "... there is a tool which makes it easier to start. It is called Extension builder" ( https://docs.typo3.org/typo3cms/CoreApiReference/ExtensionArchitecture/CreateNewExtension/Index.html )
Ttherefore I have installed this "Extension Builder"
via Zip from https://extensions.typo3.org/extension/extension_builder/
Download ZIP file
Log into your TYPO3 backend
Go to Extension Manager module
Press the upload button on the top bar
Select the ZIP file and upload it.
and with me it looks very different as in the documentation:
then i read "Docs » Creating a first extension » Create Folder Structure And Configuration Files" (https://docs.typo3.org/typo3cms/ExtbaseFluidBook/4-FirstExtension/2-create-folder-structure-and-configuration-files.html)
There they talk about "unique identifier of our extension". whats this?
"as store_inventory". whats this?
anyway.
and "These are in the folder typo3conf/ext/"
but this folder does not exist in my installation.
I then looked into an installation of another computer days later and there was this folder also not.
anyway.
i created then "typo3conf/ext/store_inventory" (as described there).
then I wondered about the following formulation:
"The name of this folder must be written like the extension key"
So this folder probably had to be different named?
then i found this folder structure at the same page:
https://docs.typo3.org/typo3cms/ExtbaseFluidBook/_images/figure-4-1.png
and I wondered a lot about the amount of folders and files.
I just wanted to make a simple extension that just lists files.
I thought that's a few lines of source code.
is not that any easier?
I do not need all these things like eg. ext_icon.gif. i hope i do not need to create all that files and folder manually.
Here are some answers:
The extension key is the name of your folder inside of "typo3conf/ext". I recommend not using an underscore because it might be confusing for you later on as a beginner with TYPO3. Choose a simple and short name. To make sure the name is not available already, please check "extensions.typo3.org" to see if the key (extension name) is already taken. If you want to be 100% sure, you have to register an account there and register the extension key officially. This is all free of course.
The file ext_icon.gif is indeed not necessary, but looks nice when your extension is shown in the list of extensions in the Extension Manager of TYPO3.
You say you want to "list files". I guess you are talking about static files like images etc. that you have in your fileadmin folder already?
So in this case you need a minimum folder structure like this:
store_inventory
Classes
Controller
StoreController.php (Contains PHP function "filesList")
Configuration
TypoScript
Resources
Private
Templates
Files.html (Contains HTML/Fluid-Code for Frontend)
ext_emconf.php (Contains necessary information about your Ext.)
ext_localconf.php (Contains registration of Frontend-Plugin/Controller)
A more detailed answer requires more information about your extension's exact requirements. Here are some more links that I think you might need for this project:
ext_emconf.php
https://docs.typo3.org/m/typo3/reference-coreapi/master/en-us/ExtensionArchitecture/DeclarationFile/Index.html#
ext_localconf.php
https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/4-FirstExtension/7-configuring-the-plugin.html
Controllers and Actions:
https://docs.typo3.org/m/typo3/book-extbasefluid/master/en-us/7-Controllers/1-Creating-Controllers-and-Actions.html
Your Controller needs to have a function called for instance "fileAction" and the template file for this "Action" must be named "File.html" in order to work. If you name the action "fileListAction", your template file must be named "FileList.html" and so on...
There are some other small things to think about, but I don't know enough about your exact requirements. If you have any trouble, don't hesitate to ask more questions!
I know, TYPO3 can be frustrating. I do it for decades already ;)
Good luck

Create an app in Wit.ai from zip

I'm trying to build a sample app in Wit.AI, with a lot of entity values and expressions. Thus, to create that app manually is not an option.
I've tried their "import" feature, but it seems it doesn't work very well or it might be very capricious about the zip. The things I've done and nothing gave a result:
Download a zip from another app in my account
Change the zip command in order to work for the new app
The changed files are expressions.json and a single file in the entities folder, describing an user-defined entity.
Zip the whole folder in order to preserve the structure of the ZIP
Nevertheless how many approaches I've tried (format the JSON and etc.) nothing worked! The server returns 400 Bad Request response.
Further, I've tried with their Web API, but to no avail again. When I'm updating the values of an entity the server responses with Success, the response doesn't contain the new values...
I've checked this article Error importing app from backup on wit.ai and many others as well as some issues on GitHub, but again...nothing helped ;)
So, if anyone could help on that...He/she gets a beer! :)
When you create a new app, you can simply upload the the zip file in Import your app from a backup, and create the new app.
To be sure to not include any redundant files in the app zip file, it is important to use the following to zip app files:
zip AppName.zip AppName/app.json AppName/entities/*.json AppName/expressions.json
and upload AppName.zip.
Note that, the name of new app, zip file, and app name in app.json file, all should be the same (here AppName).

What's the difference between 'pelican ./content' and 'make html'?

I start studying Pelican today because I want to move my blog from wordpress to pelican.
However, after reading the docs, I still don't know the difference between pelican ./content and make html. They both seem to generate a static website. Besides, pelican ./content always returns a UnicodeDecodeError** for me, whilepelican ./content` does not.
What's the difference between them and why?
In the folder where you use $ pelican-quickstart, you will find a file named Makefile.
You will find a line like this html: clean $(OUTPUTDIR)/index.html, and $(OUTPUTDIR)/%.html:
$(PELICAN) $(INPUTDIR) -o $(OUTPUTDIR) -s $(CONFFILE) $(PELICANOPTS).
This file show you what pelican have done when you type make ***, and you can config many other things in this file.
pelican ./content runs the generation of the website using defaults and trying to guess the location of your content, output and configuration files.
make html calls pelican, but explicitly gives it the input directory, the output directory, the configuration file and, optionally, some extra options.
Basically, make html (along with make regenerate) are convenience methods that make the job a bit easier for you. In any case, you should run make publish to generate the content that is to be uploaded to your web server, as it loads the publishconf.py files, which define a few extra options (the rss feeds) and allows you to change settings for the "proper" website.