fine-uploader
fine-uploader copied to clipboard
5 - Upload directly to Google Cloud Storage
I had a quick search to see if there was a tutorial for this but no luck. Is there a way to modify the server side script so that Fineuploader saves to Google Storage?
https://developers.google.com/appengine/docs/php/googlestorage/
This would be very handy.
@engagingcomms You can send the files to whatever location you choose, as the server is entirely under your control. Fine Uploader is exclusively a client-side library. You can use Fine Uploader's traditional endpoint handler to send files to your specific server, where you can then relay the files to Google Storage using the GS API.
Has anyone done this before / have some sample code? As I have no idea :)
In particular with Google App engine you can't save locally at all, has to be direct to storage.
It looks like GCS supports CORS, so it seems like we could upload directly to a bucket from the browser, à la Fine Uploader S3/Azure. Is this what you are wondering about?
Yes that would be ideal. Upload to a Google Bucket with a unique file name, then return that filename to the Google APP. Not to sure where to start though.
It's something we can look into directly supporting in a future release. Theoretically, it's possible without our intervention, but a specific Google Cloud Storage module for Fine Uploader would make it easier, so you don't have to worry about the details of the GCS API. We'll discuss this internally.
Nice one cheers.
We might be able to easily support this via the s3 compatibility layer provided by cloud storage.
That would be awesome. The Google APP engine doesn't allow you to store directly to server so this would be a very valuable script.
The work completed in #1332 may make this possible, assuming the Google Cloud Storage S3 integration layer is enabled. Any Google Cloud Storage users want to confirm with the pre-release of 5.1.0? If you find issues, we'll fix them as part of 5.1.0. Otherwise, we'll look into this more in a future release.
Hi - How can I get a copy of the pre-release of 5.1.0? Thanks.
We plan to release 5.1.0 this week, so you will be able to give this a spin in the released version.
On Mon, Dec 29, 2014 at 5:57 PM, kngtr [email protected] wrote:
Hi - How can I get a copy of the pre-release of 5.1.0? Thanks.
Reply to this email directly or view it on GitHub: https://github.com/FineUploader/fine-uploader/issues/1158#issuecomment-68316969
@kngtr Have you downloaded 5.1? If so, are you interested in using it to upload directly to Google Cloud Storage?
I would be, do you have a working php sample I could try?
R
On 7 Jan 2015, at 8:09 am, Ray Nicholus [email protected] wrote:
@kngtr Have you downloaded 5.1? If so, are you interested in using it to upload directly to Google Cloud Storage?
— Reply to this email directly or view it on GitHub.
We have a number of Fine Uploader S3 PHP samples in the server-examples repo. You'd use Fine Uploader S3 and setup Google Cloud Storage to use S3 compatibility mode. The S3 feature page will provide some additional details, if you need them. Uploading to Cloud Storage with S3 compatibility mode enabled would qualify as an "S3-like" endpoint, which, in theory, should be supported now after changes made in 5.1.
When constructing Fine Uploader S3 client-side, you'd need to specify the Cloud Storage endpoint as request.endpoint
and the bucket in objectProperties.bucket
.
Thanks rnicholus. I will download and give it a try.
I'm a google cloud user and I'd love to test this out. I'm a little confused on how to integrate it though using the s3 compatibility mode. Has anyone tried this or explain it a little more in depth?
@bryangoldberg What, specifically, are you stuck on? The Google Cloud Storage docs cover a "simple migration" from S3 to Cloud Storage, which allows a CS endpoint to be treated as if it were an S3 bucket.
Has anyone had a chance to test this out with Google Cloud Storage's S3 compatibility mode yet?
Not yet. Hopefully I will let you know next week.
Ray - I gave a quick try this morning and ran into 'Invalid policy document or request headers!' error. I already replaced AWS-ACCESS-KEY with GOOG-ACCESS-KEY so I will debug more later.
You'll need to ensure all access keys server side are your cloud storage keys. Also, the credentials.accessKey
client-side Fine Uploader S3 option must be set to your GCS access key.
It's far too confusing to set up a google cloud storage upload through the s3. If anyone is trying to, an easy alternative I found is the following (if you are using app engine):
require_once 'google/appengine/api/cloud_storage/CloudStorageTools.php';
use google\appengine\api\cloud_storage\CloudStorageTools;
$options = [ 'gs_bucket_name' => 'bucket' ];
$upload_url = CloudStorageTools::createUploadUrl('/upload-url', $options);
Then you'll want to store $upload_url
into a variable like so:
<script>var upload_link = "<?php echo $upload_url; ?>"</script>
And then continue your fineuploader like normal. Notice the endpoint is the new upload_link
variable.
var upload_template = $("#upload_template").fineUploader({
request: { endpoint: upload_link },
autoUpload: false, validation: { sizeLimit: 5000000, itemLimit: 1, allowedExtensions: ['pdf'] },
}).on('complete', function (event, id, name, responseJSON) {
});
Then in your /upload-url
have the following to move your new temporary uploaded file:
move_uploaded_file($_FILES['qqfile']['tmp_name'], 'gs://bucket/new_file.pdf');
And boom, you've uploaded a file to your cloud storage to do whatever you want using fine uploader.
It looks like you are essentially uploading the file twice (once to your server, then again from your server to the final storage destination), something that Fine Uploader S3 aims to prevent. So, you're not using Fine Uploader S3 at all. Is this correct?
App Engine doesn't allow for writes to the server, only the Cloud Storage, so I "think" it's only uploading it once and then basically renaming the file and making it available in google cloud storage. It's in a hidden temp storage at the time of upload and needs to be moved with move_uploaded_file()
.
But that is correct, I am currently just using the default Fine Uploader script. I wish I had the time to wrap my head around the Fine Uploader S3, but since I've never used anything CORS or anything in S3 before it's a tad confusing for me.
Hmm, ok. I'll admit I'm not very familiar with app engine. Not very = not at all. Thanks for posting this, perhaps it will be useful for others using AE.
I hope to spend some time playing around with GCS after the current in-progress release of Fine Uploader is out the door (5.2).
No problem, that was the goal. Thanks for such a simple and easy uploader tool. It REALLY helped me out. Looking forward to the next release. If you need any help messing with GCS in the future, I'd be happy to try some things out.
Shelving this until sometime after 5.3, unless someone reports success using Fine Uploader S3 w/ CDN support in the meantime.
Has anyone tried this lately?