Where do I put the require code for autoloader.php? - drupal-7

I am clearly new at this. But I'm having trouble installing the google-api-php-client library. On Google's documentation page, it says:
After obtaining the files, include the autloader. If you used Composer, your require statement will look like this:
require_once '/path/to/your-project/vendor/autoload.php';
If you downloaded the package separately, your require statement will look like this:
require_once '/path/to/google-api-php-client/vendor/autoload.php';
I know this is probably an simple answer, but where in my project am I supposed to put the code?
Is there a file within the google-api-php-client directory that I am supposed to put this line in? Or do I need to place this line directly into my website's html in order for the library to properly install?
I am using Drupal 7 and I installed the library with composer.

Suppose I have 3 files, mail.php, calendar.php and drive.php. With mail.php, I run a script that sends emails from my google account, with calendar.php I run a script that inserts a new event in my calendar and with drive.php I run a script that uploads a file to my drive. Each one of those files will need the require_once '/path/to/your-project/vendor/autoload.php'; after <?php. For example:
<?php session_start();
require_once '/path/to/your-project/vendor/autoload.php';
//run the rest of your script that requires interacting with google services.
Please take a look at the example in the documentation located here and the example here

Related

How to show Image from local drive in Angular JS [duplicate]

I'm trying to retrieve a picture from my file system after a good storage,(instead of putting it in the database I copy it to the disc and i put the path to the db)
I had store the picture to c:\images\ folder and supposing that the name the complete path is c:\images\mypic.jpg
when I try to retrieve it a set the img src attribute to <img src="c:\images\mypic.jps"> by using some java code
in the browser console I found this error Not allowed to load local resource: file:///C://images//mypic.jpg
Question: how to fix these path problem ? where Should I store the pictures ? and from where should I retrieve them ?
sending tag <img src="c:\images\mypic.jpg"> would cause user browser to access image from his filesystem.
if you have to store images in folder located in c:\images i would suggest to create an servlet like images.jsp, that as a parameter takes name of a file, then sets servlet response content to an image/jpg and then loads bytes of image from server location and put it to a response.
But what you use to create your application? is it pure servlet? Spring? JSF?
Here you can find some info about, how to do it.
In Chrome, you are supposed to be able to allow this capability with a runtime flag --allow-file-access-from-files
However, it looks like there is a problem with current versions of Chrome (37, 38) where this doesn't work unless you also pass the runtime flag --disable-web-security
That's an unacceptable solution, except perhaps as a short-term workaround, but it has been identified as an issue:
https://code.google.com/p/chromium/issues/detail?id=379206
You have Two alternatives :
First one is to create a ServletImageLoader that would take as a parameter an identifier of your image (the path of the image or a hash) that you will use inside the Servlet to handle your image, and it will print to the response stream the loaded image from the server.
Second one is to create a folder inside your application's ROOT folder and just save the relative path to your images.
Many browsers have changed their security policies to no longer allow reading data directly from file shares or even local resources. You need to either place the files somewhere that your tomcat instance can serve them up and put a "regular" http url in the html you generate. This can be accomplished by either providing a servlet which reads and provides the file putting the file into a directory where tomcat will serve it up as "static" content.
The concept of http location and disk location is different. What you need to do is:
for uploaded file summer.jpg
move that under a known (to the application) location to disk, e.g c:\images\summer.jpg
insert into db record representing the image with text summer.jpg
to display it use plain <img src="images/summer.jpg" />
you need something (e.g apache) that will serve c:\images\ under your application's /images. If you cannot do this then in step #2 you need to save somewhere under your web root, e.g c:\my-applications\demo-app\build\images
This error means you can not directly load data from file system because there are security issues behind this. The only solution that I know is create a web service to serve load files.
Here is a simple expressjs solution if you just want to run this app locally and security is not a concern:
On your server.js or app.js file, add the following:
app.use('/local-files', express.static('/'));
That will serve your ENTIRE root directory under /local-files. Needless to say this is a really bad idea if you're planning to deploy this app anywhere other than your local machine.
Now, you can simply do:
<img src="/local-files/images/mypic.jps"/>
note: I'm running macOS. If you're using Windows you may have to search and remove 'C:\' from the path string
Do not use ABSOLUTE PATH to refer to the name of the image for example: C:/xamp/www/Archivos/images/templatemo_image_02_opt_20160401-1244.jpg. You must use the reference to its location within webserver. For example using ../../Archivos/images/templatemo_image_02_opt_20160401-1244.jpg depending on where your process is running.

upload and download files by user in opencms 9

I am trying to create upload and download the files option by user from front-end created in OPENCMS 9. Could you please suggest/help me to get the solution as how to approach or any predefined modules available for the same.
I have already serached for the same and got some module "Synyx NetbeansOpenCmsUpload Module" but couldn't able to download this. Please suggest.
Take a look to the jLAN Function of OpenCms:
http://documentation.opencms.org/opencms-documentation/more-opencms-features/mounting-the-vfs/network-share-access/index.html

Watson document conversion not working for my downloaded pdf files

i tried following the steps mentioned "https://github.com/watson-developer-cloud/document-conversion-nodejs" and is able to load the app which works well with sample pdf file.
But when i try using my pdf file it throws error "Missing required parameters:
either params.file or params.document_id must be specified"
Also in the above mentioned git hub link the step 7 is not clear, it mentions run node setup.js but i am not able to find out that file.
has anybody faced this kind of issue.Kindly reply.
Thanks for pointing out the confusing step 7 in the document-conversion-nodejs repo. That's not a valid step and I've submitted a pull request to remove it.
You should be able to change the sample files with your own, if this is what you are trying to do. I would need to see some of your code to maybe figure out what is going on with it.
There is an alternative repository [watson-developer-cloud/node-sdk] that you also can use to create your NodeJS application. It also has an example (examples/document_conversion.v1.js) on how to run the service.
Besides entering your service credentials, all you need to do is place the document you want to convert in the "resources" folder and point to it in this line:
fs.createReadStream(__dirname + '/resources/YOUR_DOCUMENT')
The tutorial and the API documentation could also be of help.

Sencha cmd separate folder in build

I need to separate an folder in my application in another app.js build
generated by sencha cmd, this folder is being used by another applications and i need to have in web cache.
I read the documentation and I dont found nothing related to this
Exists another way to do this, without having to create a unique application for the specific folder ?

Problem with database in CodeIgniter

I downloaded the last version of CodeIgniter and I tried to run a simple app. The code works perfectly without database, but when I added this
$autoload['libraries'] = array('database');
the page went to blank.
I looked at the logs files but I didn't find anything, I check differents tutorial, but my database.php file looks correctly configured. I removed it from the array.
$autoload['libraries'] = array('');
and added to the controller this:
$this->load->library('database');
Then, this error appeared
An Error was encountered
Unable to load the requested class: database
What I do? Any clue?
Thanks in advance
To autoload the database, you use $autoload['libraries'].
$autoload['libraries'] = array('database')
Or, to load it manually, you use:
$this->load->database();
The database driver is not a normal library, it follows some weird rules.
To use the database you need to use the 'library' autoload instead of the 'config' auto load
$autoload['libraries'] = array('database');
This will actually automatically load up your configurations.
UPDATE
Another thing you mention in your question is that you 'add' that line, you do not need to add that line, you are suppose to add the element to the array that already exists on that line. You potentially could be overwriting other autoloaded libraries, I will need to see your autoload.php file to confirm this.

Resources