Al Hooton
Posts: 0
Joined: Sat Apr 19, 2014 3:02 pm

How can I generate content for a file in server code and then create a file in the Files collection with that content?

I have server code written that generates content for a small file into a variable. I don't want to send this as a file to the client, rather, I want to create a file in the Files collection with this content. All the examples I'm finding for working with the Files collection assume this is being driven from the client, but I want to do it from server code.

Illya Stepanov
Posts: 0
Joined: Mon Mar 18, 2013 8:48 am

How can I generate content for a file in server code and then create a file in the Files collection with that content?

Hi Al -

Sorry for the delay, we need to clarify this issue with our developers.
We'll update when we get more information.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

How can I generate content for a file in server code and then create a file in the Files collection with that content?

You can use server code XHR and Upload files service to do what you want.

Please read documentation about uploading files:

http://docs.appery.io/documentation/b...

To understand how work with XHR see the following code:

pre
var requestBody = {

"status": "sent",

"payload": {
"message": "Hello World",
},

"filter": {
"deviceID": deviceID
}
};

var request = {

"headers": {

Code: Select all

 "X-Appery-Push-API-Key": pushApiKey, 
 "Content-Type": "application/json" 

},

"body": JSON.stringify(requestBody)

};

var XHRResponse = XHR.send("POST", "https://api.appery.io/rest/push/msg", request);
/pre

Return to “Issues”