How to upload custom image from DO Spaces without making it publicly available ?

Posted October 9, 2020 1.1k views
Custom ImagesDigitalOcean SpacesNeeds Product Answer


Having preconfigured system image, containing some sensitive data, I would like to upload it from Spaces without making it publicly available, even for a moment. I found out that it is possible from this tutorial:
However, there are no details on how to do that in that tutorial, just mentioned that it may be done with DO API. So, I started exploring both DO API and AWS S3 API because DO Spaces API is interoperable with AWS S3 API. After having some tests done I figured out that the way to achieve my goal is using presigned links. Presigned link gives a time-limited access to private file in DO Spaces. I created such link using boto3, an AWS SDK for Python, and did some tests with it. Unfortunately, I was not able to upload a custom image from Spaces using created presigned link. Every time when I tried to use it I got a response:

{"id":"bad_request","message":"Your source URL is unreachable"}

I did the same test with Spaces file permissions changed for public. It did not help at all. Then, I tried to use this link to import a custom image via URL with DO control panel form but it ended with an error as well. I got a message:

The URL you have entered ends in an extension that we do not support. We only accept image files that end in gz, bz2, vmdk, vhdx, qcow, qcow2, vdi, raw, img, xz. (.zip is not supported).

I want to emphasize that the same presigned link worked perfectly when it was entered in internet browser’s address bar.

Concluding, I believe there is a bug in DO API, in the code checking file type in entered URL. It works well when URL ends with the file extension but my presigned link looked like:

However, more important thing for me is to find another way to upload custom image from Spaces without making it publicly available. Does anybody know another way to get it ?

edited by AHA

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer