Is it possible to delete a file uploaded on cloud storage by the API? If yes, I did not find the documentation, can you give the link?
Is it possible to browse the files uploaded with the web interface? Or manage them, see the current quota?
Thank you
Best Answer
C
Customer Support
said
over 5 years ago
Hi Vincent,
Sorry for the delayed response, I've figured out a way for you to build you own uploadedFiles collection which you can then use to create a file browser in the manage screen. Navigate to Cloud Code>User Messages> UploadCompleteMessage and paste in the code below. With this in place each time you upload a file the critical info you require will also be duplicated into the runtime collection "uploadedFiles"
//this will grab the uploadedData that we need from the response
var dataToGrab = Spark.getData().uploadData;
//load the collection
var uploadedFiles = Spark.runtimeCollection("uploadedFiles");
//insert the info into into our collection
var success = uploadedFiles.insert({"uploadedData":dataToGrab})
Then I created an event called "deleteUpload" and gave it a single string attribute called "uploadId" set to be "Used In Script", in the cloud code for that event I placed the following.
//load the collection
var uploadedFiles = Spark.runtimeCollection("uploadedFiles");
//get the uploadId that we passed in through the event
var uploadId = Spark.getData().uploadId;
//delete the file from the system
Spark.getFiles().deleteUploadedFile(uploadId);
//remove the file from our custom collection
var fileToRemove = uploadedFiles.remove({"uploadedData.uploadId": uploadId });
//display what file has been removed
Spark.setScriptData("File Removed", uploadId);
Hope this helps, if you have anymore questions just let me know.
Sorry for the delayed response, I've figured out a way for you to build you own uploadedFiles collection which you can then use to create a file browser in the manage screen. Navigate to Cloud Code>User Messages> UploadCompleteMessage and paste in the code below. With this in place each time you upload a file the critical info you require will also be duplicated into the runtime collection "uploadedFiles"
//this will grab the uploadedData that we need from the response
var dataToGrab = Spark.getData().uploadData;
//load the collection
var uploadedFiles = Spark.runtimeCollection("uploadedFiles");
//insert the info into into our collection
var success = uploadedFiles.insert({"uploadedData":dataToGrab})
Then I created an event called "deleteUpload" and gave it a single string attribute called "uploadId" set to be "Used In Script", in the cloud code for that event I placed the following.
//load the collection
var uploadedFiles = Spark.runtimeCollection("uploadedFiles");
//get the uploadId that we passed in through the event
var uploadId = Spark.getData().uploadId;
//delete the file from the system
Spark.getFiles().deleteUploadedFile(uploadId);
//remove the file from our custom collection
var fileToRemove = uploadedFiles.remove({"uploadedData.uploadId": uploadId });
//display what file has been removed
Spark.setScriptData("File Removed", uploadId);
Hope this helps, if you have anymore questions just let me know.
Thanks,
Liam
V
Vincent Themereau
said
over 5 years ago
Thank you!
V
Vincent Themereau
said
over 5 years ago
I found how to delete: by using the Spark.deleteUploadedFile("myUploadId"); from cloud code. But I'm still looking for a way to browse the uploaded file (for admin reason).
Vincent Themereau
Hello,
I have two quick questions:
Is it possible to delete a file uploaded on cloud storage by the API? If yes, I did not find the documentation, can you give the link?
Is it possible to browse the files uploaded with the web interface? Or manage them, see the current quota?
Thank you
Hi Vincent,
Sorry for the delayed response, I've figured out a way for you to build you own uploadedFiles collection which you can then use to create a file browser in the manage screen. Navigate to Cloud Code>User Messages> UploadCompleteMessage and paste in the code below. With this in place each time you upload a file the critical info you require will also be duplicated into the runtime collection "uploadedFiles"
Then I created an event called "deleteUpload" and gave it a single string attribute called "uploadId" set to be "Used In Script", in the cloud code for that event I placed the following.
Hope this helps, if you have anymore questions just let me know.
Thanks,
Liam
- Oldest First
- Popular
- Newest First
Sorted by PopularVincent Themereau
Thank you for your response.
Customer Support
Hi Vincent,
Sorry for the delayed response, I've figured out a way for you to build you own uploadedFiles collection which you can then use to create a file browser in the manage screen. Navigate to Cloud Code>User Messages> UploadCompleteMessage and paste in the code below. With this in place each time you upload a file the critical info you require will also be duplicated into the runtime collection "uploadedFiles"
Then I created an event called "deleteUpload" and gave it a single string attribute called "uploadId" set to be "Used In Script", in the cloud code for that event I placed the following.
Hope this helps, if you have anymore questions just let me know.
Thanks,
Liam
Vincent Themereau
Thank you!
Vincent Themereau
I found how to delete: by using the Spark.deleteUploadedFile("myUploadId"); from cloud code. But I'm still looking for a way to browse the uploaded file (for admin reason).
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2486 topics