Joseph Francis
Posts: 0
Joined: Thu Sep 04, 2014 8:52 pm

SIRV plugin missing?

I added the SIRV plugin but I see no service(s) created in relation to SIRV. I can't see anywhere where I'm supposed to manage

Uploading files to SIRV, Deleting files from SIRV, Adding Directories to SIRV, and Deleting Directories on SIRV, have they been put in some secret place?

Likewise, I can't see anywhere where I'm supposed to set my SIRV bucket, SIRV key, and SIRV secret. Are they not in a parameter file somewhere?

What's the purpose of the SIRV plugin?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

SIRV plugin missing?

Hello Joseph,

You will find more information concerning SIRV work here https://blog.appery.io/2014/10/proces...
Also this post should be useful https://getsatisfaction.com/apperyio/...

Jacket
Posts: 0
Joined: Wed Aug 13, 2014 11:37 am

SIRV plugin missing?

Hi Joseph,

The plugin is a demo of what Sirv can be used for. It doesn't help you use Sirv but you can install and inspect the workings of the plugin to see how it connects to Sirv and fetches images.

You can also see how images are fetched from Sirv using HTTP requests here:

https://sirv.com/resources/documentat...

Other documentation on the Sirv website shows you how to embed zoomable images and 360 spin images.

Jake from Sirv

Joseph Francis
Posts: 0
Joined: Thu Sep 04, 2014 8:52 pm

SIRV plugin missing?

Thanks guys - to be honest it's not really useful if you can't upload files, but figured out uploading eventually.

Here's code I used which may help others. Apologies for not being a stylistically good programmer.

prefunction sizedImage(area, target, name) {

/*

Code: Select all

takes input filename assumed to be in SIRV 
adds the SIRV resizing flags as appropriate 
downloads & caches the file at the resized-size in local browser HTML5 filesystem 
then puts the result cached URL in either an IMG or as Background 
stores the original url path in the element as an attribute (linkName) 

each image @ each size downloaded once until app removed 
fantastic for thumbnails and frequent-use images 

NOTE: if you happen to pass an APPERY file object... function fails gracefully 
the size flags won't cause problems, but the cached image will be full-size 
you will not have the speed of resized and cached small images for refreshes 

area = src | url 
target = jquery target element 
name = url of stored SIRV file 

*/

Code: Select all

 var width = $(target).width(); 
 var height = $(target).height(); 
 var url = name.split("?")[0];  // clean url 
 $(target).attr("linkName", url); // store clean url 

//callbacks defined 
var _success = function(a, b) { 
     console.log("Cacheing: success"); // returned ok 
 }; 

 var _failed = function(a, b) { 
     console.log('Cacheing: failed'); // problem with cache 
 }; 

 var _cacheImgFile = function(file, path) { // result of request for img cache hit 
     if (path !== undefined) { // got a cache url (!= original file name at all) 
         $(target).attr("src", path);  
         _success(); 
     } else { // no cache hit 
         $(target).attr("src", file); 
         ImgCache.cacheFile(file, _success); // save the file 
     } 
 }; 

 var _cacheBackgroundFile = function(file, path) { // req or background-image 
     if (path !== undefined) { // got it 
         $(target).css("background-image", "url(" + path + ")"); 
         _success(); 
     } else { // no cache hit 
         $(target).css("background-image", "url(" + file + ")");  
         ImgCache.cacheFile(file, _success); // save the file 
     } 
 }; 

 // variable logic 
 switch (area) { 
     case "src": 
         url = url + "?scale.width=" + width; 
         if (globalImageCacheOn) { 
             ImgCache.getCachedFileURL(url, _cacheImgFile, _cacheImgFile); 
         } else { 
             $(target).attr("src", url); 
         } 
         break; 
     case "url": 
         url = url + "?scale.width=" + width; 
         if (globalImageCacheOn) { 
             ImgCache.getCachedFileURL(url, _cacheBackgroundFile, _cacheBackgroundFile); 
         } else { 
             $(target).css('background-image', 'url(' + url + ')'); 
         } 
         break; 
     default: 
 } 

}

/*

Code: Select all

 upload file to SIRV system using AWS S3 logic 
 must preload the amazon javascript somewhere before calling this 

 var script = document.createElement('script'); 
 script.type = 'text/javascript'; 
 script.src = "https://sdk.amazonaws.com/js/aws-sdk-2.1.43.js"; 
 head.appendChild(script); 

*/

function uploadSirvFile(file, name, result) {

/*
set up AWS configuration with SIRV account (don't distribute your keys)
set up AWS endpoint for SIRV
point to bucket set up with SIRV account
set up file transfer information (I use my /input area)

Code: Select all

 file = file object an  type element 
 name = target file name 
 result = asynchronous callback 

*/

// set up AWS with SIRV account keys

Code: Select all

 AWS.config.update({ 
     accessKeyId: '', 
     secretAccessKey: '', 
     s3ForcePathStyle: true 
 }); 

// dictated by SIRV

Code: Select all

 var ep = new AWS.Endpoint('s3.sirv.com'); 

// MYBUCKET also comes from SIRV

Code: Select all

 var bucket = new AWS.S3({ 
     params: { 
         Bucket: '' 
     }, 
     endpoint: ep 
 }); 

 var params = { 
     Key: "input/" + name, 
     ContentType: file.type, 
     Body: file 
 }; 

// shoot it to SIRV. Will call result when finished

Code: Select all

 bucket.upload(params, result); 

}/pre

So there you go.

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

SIRV plugin missing?

Thank you for sharing.

Return to “Issues”