FileStack extension

Hi all,
in a my recent project I had the need to upload images on the web and then download or delete. I looked for this and at the end I decided to use Filestack. (www.filestack.com)
To use Filestack first of all You have to register an account, and the system give You an API key, with this API Key You can upload and download files (I tried only image files).
To Overwrite or Delete files You have to activate on Filestack "Use Security" you find this under Security/Policy & Signature, after activation You have a unique Secret Key.

UploadNoS
To Upload a file without Security
Object Location: the file path in your phone
FileType: for example image/jpg
ApiKey: your Api Key provided by Filestack

UploadWithS
To Upload a file with Security
Object Location: the file path in your phone
FileType: for example image/jpg
ApiKey: your Api Key provided by Filestack
SecretKey: your Secret Key provided by Filestack

Overwrite
To Overwrite a file
Object Location: the file path in your phone
Handle: this is the "place" where the file is saved on Filestack
FileType: for example image/jpg
ApiKey: your Api Key provided by Filestack
SecretKey: your Secret Key provided by Filestack

Delete
To Delete a file
Handle: this is the "place" where the file is saved on Filestack
ApiKey: your Api Key provided by Filestack
SecretKey: your Secret Key provided by Filestack

CalculatePS
Before to Download a file, when You have the Security enable, You have to calculate the Policy & Signature.
SecretKey: your Secret Key provided by Filestack

GetPS
This is the result after calculatePolicyAndSignature

GetResponse
After You Upload a file, Filestack reply with the Handle, the Handle is a unique id that You have to save because it is necessary to retrieve the file uploaded!

Download
here is an example of how to download an image file with Security enable

Source Code:
FileStack.txt (14.6 KB)
Extension:
FileStack.aix (22.1 KB)
Sample Project:
UploadImage.aia (25.7 KB)

How works the sample project:

  1. Take a Pic.
  2. Upload the image
  3. Download the image
  4. Take another pic
  5. Overwrite image
  6. Download the image
  7. Delete last image

I hope You find useful

Best Regards

Marco Perrone

7 Likes

Thank you for your contribution.

Please observe naming conventions

A link to the FileStack website would also be useful....

2 Likes

Hi,
thanks for suggestion,
I uploaded the new file extension with the correct Naming Conventions (I did not change the image in the previous post) and I added the Filestack website link.
Ciao
Marco

When you get a moment, please update the images, to avoid confusion, and others following on from you.

Done!

Nearly....

All the method and event names should start with a capital letter...

e.g.

.uploadToFileStack

should be

.UploadToFileStack

Suggestion :

Instead of taking the apiKey and secretKey values in blocks, make them designer properties, as these values don't need to be changed everytime one tries to upload, overwrite or delete files, and the same apiKey will be used everytime for most cases.

Thank You for your tip, very good, when i have a few time i do the update
Ciao Marco

1 Like

What are the advantages of using Filestack instead of cloud db ?

usually you like to protect this sensitive information as much as possible... this is possible in the blocks using the obfuscate block... however it would not be possible in the designer...
therefore @Marco_Perrone let me suggest to keep it as it is...

Taifun

Hi @patel, they are different things , cloud db is a database Filestack is a "place" to store your files.
I think to make a comparison We could say, what is better to use CloudDB or Firebase? (for example).

You can store files on Cloud db but you have to do a Base64 convertions on upload and download (correct?).
On Filestack the file is immediately available, You can see it on a browser for example
Ciao
Marco

Hi @Taifun,
thank You , I think at the end I will follow your tip, as @SHUBHAMR69 suggested the code is much clean for the user that do not need to add the same values many times, but your argumentation about sensitive information I think is more important.

Thank You to all for yours contibution.

Ciao Marco

You can store files on Cloud db but you have to do a Base64 convertions on upload and download (correct?)

.

Incorrect, cloudDB is now fixed, you can save binary files, upto 5mb each, directly, if you give a full path to the file, and only try to store one file to a tag. You may need to create a folder called AppInventorBinaries in your ASD/files folder, which is where the stored files are returned, with a different file name.