I have a problem with inserting images in a google document with app scripts.
All my images are stored in https://storage.cloud.google.com with format https://storage.cloud.google.com//100x120/86d932ad-b649-4c38-adaf-ae0071ea3ecd
and my code is like this:
/**
* Insert new paragraph with parameter
*/
function createDocument(iData) {
var doc = DocumentApp.getActiveDocument();
var body = doc.getBody();
// Access the body of the document, then add a paragraph.
// Retrieve an image from the web.
var resp = UrlFetchApp.fetch(iData[5])
Logger.log(resp.getContentText());
var celdas = [
[iData[5], 'User: ' + iData[0]],
[, 'Name: ' + iData[1]],
[, 'U.O. : ' + iData[2]],
[, 'Email : ' + iData[3]],
[, 'Phone : ' + iData[4]]
];
doc.getBody().appendTable(celdas);
doc.getBody().appendImage(resp.getBlob());
}
The info is stored in Array iData, and it´s not working.
the table is successfully created but the image does not appear
(a) You have two slashes in your image path after domain:
https://storage.cloud.google.com//100x120/86d932ad-b649-4c38-adaf-ae0071ea3ecd
There should be only one.
(b) Make sure that these images are publicly accessible. Check "Share publicly" setting in your Cloud console.
(c) Make sure that these files have correct MIME type set, e.g. "image/jpeg" - or whatever their type is. Since the file URI does not end with ".jpg", the browser may not interpret them correctly.
Related
I am using an external JSON to retrieve the name of the volcano and put all names into a drop down menu to be selected and shown on my map. Currently, I have no errors on my webpage console but I am not getting any names inside the dropdown. I am very new to coding and I am blank on what is wrong. Any advice?
'''
//Call JSON for map latitude and longitude, showing volcaones locations
// with last eruption in a hover feature
var data = {};
d3.json("./Graphs/Vol_cleaned.json").then(function (data) {
console.log(data);
// Once we get a response, send the data.features object to the createFeatures function
makeMap(data);
makeDrop();
});
//MAKE DROP DOWN MENU TO SELECT VOLCANO NAME
function makeDrop(){
for (var i = 0; i < data.Volcano_Name; i++){
let name = data.Volcano_Name[i];
d3.select("#arr").append("option").text(name);
}
}
function optionChanged() {
makeMap(data);
}
function makeMap(data) {
'''
JSON
I have tried several ways to call the data, I don't think I will be able to describe them correctly being that I am new to the coding world. My current code in the picture provide is working with no errors but nothing is populated in the drop down.
Currently have working on an image upload in a Laravel/Inertia/React stack.
Issue: It currently works using a symbolic link to the public folder. This is no good as it means anyone can access the images if they have the link. How can I do this differently so that only the owner of the image can view it?
Displaying the image:
<img src={`/storage/${props.company.logo_filename}`}/>
Storing the logo:
public function storeLogo(Request $request)
{
$company = auth()->user()->company();
$logo = $request->file('logo');
$extension = $logo->getClientOriginalExtension();
Storage::disk('public')->put($logo->getFilename() . '.' . $extension, File::get($logo));
dd(Storage::url('public/'. $logo->getFilename()));
$company->logo_mime = $logo->getClientMimeType();
$company->logo_original_filename = $logo->getClientOriginalName();
$company->logo_filename = $logo->getFilename() . '.' . $extension;
$company->save();
//DELETE old Logo if exists
return Redirect::back()->with(
'message',
[
'type' => 'success',
'text' => 'Logo Updated'
]
);
}
note: In this particular scenario (company logos) I'm aware that it probably doesn't matter if someone else gets access to the images. Please just assume they are sensitive.
You could add a route to serve the files and check if the current user is allowed to access the file.
use Illuminate\Support\Facades\Storage;
Route::get('files/{filename}', function (string $filename) {
// Do your magic to check if the current user is allowed to access that file
// Do your magic to determine the full path of the file
$fullPath = '/some/directory/' . $filename;
// Once we have the full path we can stream the contents of the file to the client
return Storage::response($fullPath);
});
Unfortunately the Storage::response() method is undocumented as far as I know, but you can find it's implementation here:
https://github.com/laravel/framework/blob/5.5/src/Illuminate/Filesystem/FilesystemAdapter.php
I want to get Full URL including URL Parameter in my module code.
For example
From This URL
http://Domain/Search-Space-For-Rent/Houston
TabController.CurrentPage.FullUrl
Gives me
//Domain/Search-Space-For-Rent
only I need to get last parameter from URL (Houston)
I also tried
Globals.NavigateURL(this.TabId, this.Request.QueryString["ctl"], UrlUtils.GetQSParamsForNavigateURL());
How can I get that?
So I regenerated URL using all query string parameters.
string path = TabController.CurrentPage.FullUrl;
foreach (string key in Request.QueryString.AllKeys)
{
if (key != "TabId" && key != "language" && key != "_escaped_fragment_")
{
if (key != null)
{
path += "/" + key + "/" + Request.QueryString[key];
}
else
{
path += "/" + Request.QueryString[key];
}
}
}
Typically within DNN you would simply get from the QueryString ex:
var myParam = Request.Querystring["paramName"];
What parameter name are you using when you build that URL? I would assume you've got a custom URL provider that changing something like "&city=Houston" to be /Houston instead. If that is the case, just grab the querystring paramter called City.
Update:
To get the "Name" of the page, assuming the scenario where Houston is a page in DNN, you could do the following.
var tc = new TabController();
var ti = tc.GetTab(TabId);
var pageName = ti.TabName
TabId comes from DNN, assuming your module inherits from PortalModuleBase you should have access to it. With that, you can then get the TabInfo from the TabController, and access the properties off that TabInfo object.
I have the following code
var resource = $resource('https://api.mongolab.com/api/1/databases/' + DB_NAME + '/collections/' + collectionName + '/:id',
{ apiKey:API_KEY, id:'#_id.$oid'},{update:{ method:'PUT' } }
);
when i call
$scope.projects = Project.query({q:"+"});
referencing
Each key value in the parameter object is first bound to url template if present and then any excess keys are appended to the url search query after the ?.
I append the Get request with the string in the {}. I cannot however include special charaters. Is this a feature and how can I implement special characters?
I believe you should urlencode values as long as you are sending them in url query
I am attempting to use a google spreadsheet as a temporary database. I have followed the instructions at the folowing tutorial and everything is working fine
http://www.alatechsource.org/blog/2012/05/using-the-google-spreadsheets-data-api-to-build-a-recommended-reading-list-code-words.h
The jquery that gets the data I have copied below for ref
I wondered if it would be possible (using the same or similar code), assuming there are multiple sheets within the spreadsheet to query just one at a time. So for example you could run the below code but only for say sheet 4.
I have tried adding sheet ref # from the web URL (i.e #gid=1) at the end of the numeric code so
"https://spreadsheets.google.com/feeds/list/0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE/od6/public/values?alt=json-in-script&callback=?"
becomes
"https://spreadsheets.google.com/feeds/list/0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE#gid=1/od6/public/values?alt=json-in-script&callback=?"
but this does not work, the code only seems to loop through the first sheet
Can anyone advise on this?
Any help is much appreciated
<script type="text/javascript">
$(document).ready(function() {
//source file is https://docs.google.com/spreadsheet/ccc? key=0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE
$(function listBooks() {
$.getJSON( "https://spreadsheets.google.com/feeds/list/0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE/od6/public/values?alt=json-in-script&callback=?",
function (data) {
$('div#book-list').append('<ul class="items"></ul>');
$.each(data.feed.entry, function(i,entry) {
var item = '<span style="display:none">' + entry.id.$t + '</span>';
item += '<img src="http://covers.openlibrary.org/b/isbn/' + entry.gsx$isbn.$t + '-S.jpg"/>';
item += '<span class="meta">' + entry.title.$t + '';
item += '<br/>Author: ' + entry.gsx$author.$t;
if (entry.gsx$notes.$t) {
item += '<br/>Description: ' + entry.gsx$notes.$t;
}
$('.items').append('<li>' + item + '</span></li>');
});
});
});
});
</script>
Ok, I have a solution for anyone who is interested, although it is not as sensible as I would have hoped
Thanks to the below blogpost
http://damolab.blogspot.co.uk/2011/03/od6-and-finding-other-worksheet-ids.html
It seems that the id for specific sheets is the /od6/ part of the URL and od6 is the default name given to the first, default, sheet
"https://spreadsheets.google.com/feeds/list/0Ak0qDiMLT3XddHlNempadUs1djdkQ0tFLWF6ci1rUUE/od6/public/values?alt=json-in-script&callback=?"
In the above blog post there is an example of how to find out the IDs of specific sheets if you need. There doesn't seem to be a clean logic to it but changing it will spit out the data from specific sheets so it works.
I realize this is an old post, but I have been fighting this for a while. I made my own library to take care of this and I hope this saves someone many hours of research and playing with the google api. The general format is almost verbatim from the google documentation and I removed error checking to stay concise. What I could not find in the google documentation was how to query a tab that isn't the first one. I think this is what we are looking for here.
Based on what you already have, this should answer it.
table_name_here/gviz/tq?sheet=tab_name_here
As an example for all those that come after you:
https://docs.google.com/spreadsheets/d/17mbdvl1jVpqj42E3BSX34q9XUA2PbYubYKpVeypbHLA/gviz/tq?sheet=Sheet1
This could be used as the table_string in the code below.
'SELECT *'
This could be used as the query_string in the code below.
Within context:
function gimmeATable(){
var query = new google.visualization.Query('table_string');
query.setQuery('query_string');
query.send(handleQueryResponse);
}
function handleQueryResponse(response){
var data = response.getDataTable;
drawTable(data);
}
function drawTable(data){
var table = new google.visualization.Table(document.getElementById('div1'));
table.draw(data, {showRowNumber: true});
}
And don't forget to include the google api as well as package type. For this you only need a table.
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
google.load("visualization", '1', {packages:['table']});