Uploading H5P Packages with OSX
This article is written by timothylim23 and assumes that you've completed the 'hello world' H5P tutorial until the stage where you have to upload a package.
When uploading h5p packages to drupal with osx, you may encouter the following errors:
Could not find library.json file with valid json format for library greeting A valid content folder is missing A valid main h5p.json file is missing
As mentioned in the comments on the tutorial page, these errors are caused by zipping the project folder as opposed to all the files within it.
We can zip all the files within the project file using the terminal (we will use the greeter tutorial as an example):
Navigate into the project
$ cd greeting
Let's have a look inside
$ ls H5P.GreetingCard content h5p.json
zip the all the files in greeting to a file called greeter.h5p
$ zip -r greeter.h5p *
Depending on whether the files in greeter have been accessed using finder, this may be successful or the following erros may occur:
File ".DS_Store" not allowed. Only files with the following extensions are allowed: json png jpg jpeg gif bmp tif tiff svg eot ttf woff otf webm mp4 ogg mp3 txt pdf rtf doc docx xls xlsx ppt pptx odt ods odp xml csv diff patch swf md textile. The uploaded file was not a valid H5P package
This error is caused by uploading DS_Store files which are created by Finder whenever you open a file.
Remove the corrupted zip file if you haven't already
$ rm -rf greeting.h5p
Recursively delete the .DS_Store files, don't open the directory in Finder after this step
$ find . -name '.DS_Store' -delete
Create the zip file again
$ zip -r greeter.h5p *
that should be it. Check out the official H5P forum if you have any other problems.
Comments
studyaid
Tue, 08/27/2019 - 21:14
Permalink
terminal command update
zip -r -D -X greeter.h5p *
-r recurse into directories
-D do not add directory entries
-X eXclude eXtra file attributes
To verify file and contents run:
zipinfo greeter.h5p
Ray1991
Mon, 03/08/2021 - 18:06
Permalink
That code work for me
zip -r -D -X greeter.h5p * works weel for wordpress5.6.2
dhenin
Sun, 11/21/2021 - 17:43
Permalink
J'ai préféré utiliser Lumi et ça marche
J'ai peiné longtemps avant de conclure que les fichiers *.json dans les h5p de wordpress ne supportent pas les retours à la ligne.
Mais, heureusement, Lumi enregistre sous le nom que l'on souhaite "Name.h5p" une version exécutable (sous lumi) au format sans retour à la ligne instempestifs qui sera aceptée par wordpress + plugin H5P.
Lumi : Fichier->Enregister sous ...
Wordpress : Menu -> Exercices H5P -> Ajouter -> Téléverser ....
"I preferred to use Lumi and it works
I struggled for a long time before concluding that * .json files in wordpress h5p do not support line breaks.
But, fortunately, Lumi saves under the name that one wishes "Name.h5p" an executable version (under lumi) in the format without uninvited line feeds which will be accepted by wordpress + H5P plugin.
Lumi: File-> Save As ...
Wordpress: Menu -> H5P Exercises -> Add -> Upload ...."