I have a business enterprise web application that I built in PHP and it is hosted on BlueHost.
I have an entity named Attachment that is a many to one to a separate entity called Ticket. The Attachment entity represents a file attachment for a Ticket. The way it currently works to upload it is:
- I give the file a unique name (random GUID + extension)
- I upload the file to the file system
- I save a new instance of the record referencing the filename in the database
Then to download it I:
- Get the Attachment record by its Id
- Search the file system by the filename defined in the record
- Return the file by its filename
This worked fine, but I ran into an issue where I was running out of memory on the server, so I talked with the client and convinced them to a cloud based storage solution and we settled on Box.
Now I’m attempting to migrate from using the file system to using Box. I have already created two directories (one for production and one for staging) and uploaded the files from the server to Box. But I’m having a difficult time figuring out how to upload/download the files. Most of the documentation either suggests having the user login using OAuth 2.0 or by using JWT.
So I have created an app using JWT as the authentication, I authorized the app for enterprise, and I have also generated a private/public key. After that, I’m a bit confused. Typically I’d expect to see something like:
- Make an API call to generate a JWT token
- Make an API call to find the file’s ID, passing the JWT token as a bearer token
- Make an API call to download the file based on the ID, passing the JWT token as a bearer token
But the documentation isn’t exactly obvious what my next steps are.