Parse CLI won't upload non-js files - parse-platform

I'm trying to send iOS push notifications using my Cloud Code (I can't use Parse's Push APIs as my app is built using ionic and all their docs expect native).
I have it working as a standalone script locally using nodejs, but when I go to upload it to parse, I get:
Uploading source files
Note that the following files will not be uploaded:
parse_cloud_code/cloud/cloud/cert.pem
parse_cloud_code/cloud/cloud/key.pem
Uploading recent changes to scripts...
The following files will be uploaded:
parse_cloud_code/cloud/cloud/cloud.js
parse_cloud_code/cloud/cloud/cloud_test.js
parse_cloud_code/cloud/cloud/credentials.js
parse_cloud_code/cloud/cloud/fs.js
parse_cloud_code/cloud/cloud/push-notification.js
parse_cloud_code/cloud/cloud/push-notifications_test.js
parse_cloud_code/cloud/cloud/tls.js
Finished uploading files
Error: Failed to load cloud/cert.pem with: Could not find file cloud/cert.pem
at Object.exports.readFile (cloud/fs.js:24:17)
at readFile (cloud/push-notification.js:45:8)
at body (cloud/push-notification.js:56:5)
at cloud/push-notification.js:147:3
at cloud/push-notification.js:156:3
at cloud/cloud.js:5073:5
at cloud/cloud.js:5082:3
at main.js:1:13
How can I get the .pem files into the cloud code? I tried renaming them to .js but then Parse wanted them to actually be syntactically JS files. Imagine that.

I found a workaround for this situation, as I had a similar problem. Any non-js file that I must upload I would rename to .ejs. So the parse CLI will upload it and them you can use it inside your cloud code.

Related

Can I run stanza NER without downloading the language modules?

I need to run stanza ner in a platform without any access to external network. The code stanza.download('en') fails. Running without the download function, gives me an exception
Exception: Resources file not found at: \home\stanza_resources\resources.json. Try to download the model again
Is there a way to download and cache all the required modules in a resource directory and point this directory to stanza pipeline?
Thanks
It looks like both download and the Pipeline class take an argument for directory dir
So the below code works
stanza.download('en', dir='resources/', processors={ner_processor: package})
nlp_pipeline = stanza.Pipeline('en', dir='resources/', processors={ner_processor: package})

Upload lambda function.zip with small size

I've 2 aws-lambda projects.
the first one is using serverless-bundle.
serverless-bundle.github
when I deploy the first project, I can see below logs
(...)
Serverless: Uploading service hello.zip file to S3 (34.56 KB)...
Serverless: Uploading service bye.zip file to S3 (12.34 KB)...
(...)
each function.zip has a small size and different size.
and
the second project is using serverless-plugin-typescript
serverless-plugin-typescript
and
(...)
Serverless: Uploading service hello.zip file to S3 (22.83 MB)...
Serverless: Uploading service bye.zip file to S3 (22.83 MB)...
(...)
each functions.zip has the same size and it has a bigger size than the first project's
I am going to use typescript, so I can't use serverless-bundle because they don't support ts yet.
so, my question is how can I reduce the functions.zip size like using serverless-bundle
Serverless framework now has native support for using typescript via aws-nodejs-typescript template.
For new projects you can create them using serverless create --template aws-nodejs-typescript && npm install
For existing projects, you just need to include serverless-webpack
plugin.
you can use serverless-webpack like this.
service:
name: my-functions
# Add the serverless-webpack plugin
plugins:
- serverless-webpack
In your case, all the zip files are different size because, the first method 'serverless-bundles' is an extension of serverless-webpack

Laravel How to download all files in a directory

Using Laravel, I am trying to make a function which would download all files in a directory from S3.
I have used to retrieve all keys of the files using $file = Storage::disk('s3')->allFiles('path');, but I do not know what to do next.
It seems like I have to download all files into local, then zip those files, then download that zip file. I would like to know if there is a better way.
Any suggestion or advice would be appreciated.
I was able to do what I wanted with this:
http://coderaweso.me/zip-and-download-files-directory-from-amazon-s3-with-laravel/
It is not possible to send more than one file simultaneously over the same request with the HTTP protocol. Laravel also does not support this. You have to pack the files in, for example, a zip file.
Install Chumper/Zipper package and return a zip containing all your files:
$files = Storage::disk('s3')->allFiles('path');
Zipper::make(public_path('test.zip'))->add($files);
return response()->download(public_path('test.zip'));

Deploying custom resource through DSC PullServer fails to extract the module

I've set up a DSC PullServer on Server 2008 R2 and I've run into an issue deploying a custom module. The module on the PullServer is in C:\Program Files\WindowsPowerShell\Modules\NTFSPermission, I've zipped everything using Windows Explorer (and 7-zip) and placed the zip in C:\Program Files\WindowsPowerShell\DscService\Modules\NTFSPermission_1.0.zip, I create a checksum using NEW-DSCChecksum for the zip file and I've got Import-DSCResource NTFSPermission in my node configuration. When I run the Invoke-CimMethod to push the config to a node it errors out with:
Invoke-CimMethod : Failed to extract the module from zip file
C:\Windows\TEMP\\635291179507191263\NTFSPermission_1.0.zip downloaded by Download
Manager WebDownloadManager.
The node logs a 4104 error in the event viewer reading:
This event indicates that failure happens when LCM is trying to get the configuration from pull server using download manager WebDownloadManager. ErrorId is 0x1. ErrorDetail is Failed to extract the module from zip file C:\Windows\TEMP\\635291179507191263\NTFSPermission_1.0.zip downloaded by Download Manager WebDownloadManager.
Has anyone else run into this? I'm not sure if there's a config file somewhere that is literally piping in an extra backslash and causing an invalid download/extraction path or if there is something wrong with the zipped module. If I move the module over manually the config will be pushed and apply successfully, which leads me to believe it's not the module.
There is a known issue with extracting zip files created using .NET compression class in 4.5. The workaround is to use the shell method of compressing files. That is, send to compressed archive option in right-click context menu or using Shell COM object.
I tested one of the modules from the DSC Resource Kit and it extracted with no problems on the desired node. I tracked the problem down to the psd file that the author created for their DSC-Resource. I updated the CLRVersion to require 4.0 and removed RequiredModules, RequiredAssemblies, ScriptsToProcess, TypesToProcess,FormatsToProcess and NestedModules (all were empty values anyway), pushed the config without the workaround and it downloaded and extracted the resource.

Perl::WSDL. Generated methods in different directory than script

I am trying to write a script for using with op5/nagios.
What it tries to do is to connect to database an get a value there, and then send a request to a webservice and match the response from the webservice with the value from the database.
Now writing the script wasn't the problem. The problem arrises when trying to run it from OP5.
When including the interface to script I use the following syntax
use MyInterfaces::PortalServicesImplService::PortalServicesImplPort;
This works just fine when I execute the script located on the same level as "MyInterfaces".
The problem is that the script itself is located in the folder /opt/plugins/custom/SOAP where both the script and the folders generated by wsdl2perl.pl is located. However when OP5 executes the script is does so from the folder /opt/monitor.
So I tried to include the "PortalServicesImplPort" using this syntax
use lib "/opt/plugins/custom/SOAP/MyInterfaces/PortalservicesImplServices/PortalServicesImplPort
The code compiles but when trying to run it I get an error message saying
Can't locate object method "new" via package "MyInterfaces::PortalServicesImplService::PortalServicesImplPort" (perhaps you forgot to load "MyInterfaces::PortalServicesImplService::PortalServicesImplPort"?)
Am I doing something wrong when importing methods from another location or doesn't SOAP::WSDL support placing the auto generated files in a different directory from where you are executing the script?
Seems I managed to solve this myself by adding use lib "/opt/plugins/custom/SOAP

Resources