Go Back   vb.org Archive > vBulletin 5 Connect Discussion > vB5 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 04-13-2017, 03:49 PM
incursio incursio is offline
 
Join Date: Nov 2001
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Bulk photo/gallery import script

Hey guys, I am trying to import thousands of existing photos into VB5. The images exist in folders/subfolders on the server. Anyone have a basic script to programmatically create a new gallery folder for a user and import a photo into it? I can probably figure it out from there if I had a sample to look at. Thanks in advance!

--------------- Added [DATE]1492107744[/DATE] at [TIME]1492107744[/TIME] ---------------

A little more info as I keep trying to figure this out on my own - when I do this:

Code:
$response = $api->callApi('content_gallery', 'add', array('data' => $data, 'options' => $options));
I get the humanverify_missing error. It would seem to me that by using the API this would be disabled for the purpose of the request being made, but nevertheless ... so I disabled the Human Verification Manager in the admin panel, and now I get a "permission denied" error coming back from the API call.
Reply With Quote
  #2  
Old 04-13-2017, 07:41 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

How are you executing the api? You should be logged in to create gallery post unless you enable permissions for guests which I assume you don't want.
Reply With Quote
  #3  
Old 04-13-2017, 10:06 PM
incursio incursio is offline
 
Join Date: Nov 2001
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks! That helped me get past that issue. Now, I am getting this response when trying to add the image:

Code:
Array
(
    [errors] => Array
        (
            [0] => Array
                (
                    [0] => unexpected_error
                    [1] => Upload failed. PHP upload error: 0
                )

        )
)
My test code looks like this:

Code:
  // This line does add the node for the album
  $albumId = $api->callApi('content_gallery', 'add', array('data' => $data, 'options' => $options));

  // Here, I get the info on a test file to try and add programatically
  $fileName = '/var/www/mydomain.com/gw/photos/Architectural/wallpaper-1st-id-arch.png';
  $fileParts = pathinfo($fileName);
  $imageName = $fileParts['filename'];

  // I don't want to lose the original file, so I copy it into a tempfile, to simulate uploading it
  $tmpName = tempnam('/tmp', 'INC');
  copy($fileName, '/tmp/' . $imageName);
  rename('/tmp/' . $imageName, $tmpName);

  $fileInfo = array();
  $fileInfo['uploadFrom'] = 'profile';
  $fileInfo['parentid'] = $albumId;
  $fileInfo['tmp_name'] = $tmpName;
  $fileInfo['name'] = $fileParts['basename'];
  $fileInfo['size'] = filesize($fileName);
  $fileInfo['type'] = 'image/png';

  $photos = array($fileInfo);

  // Upload the file and add it
  $response = $api->callApi('content_attach', 'upload', array('photos' => $photos));
  print_r($response); exit;
Any ideas?

--------------- Added [DATE]1492129123[/DATE] at [TIME]1492129123[/TIME] ---------------

Ok, I got past that problem. I needed to just pass 'file' => $fileInfo and do away with the $photos bit I was trying.

At any rate, it does "upload" the image, but now I need to somehow get it to show up in the gallery. I'm thinking I need to do something like this:

Code:
$response = $api->callApi('content_photo', 'add', ..... );
Just not sure what to pass to it.

--------------- Added [DATE]1492129263[/DATE] at [TIME]1492129263[/TIME] ---------------

Tried this, but to no avail:

Code:
$response = $api->callApi('content_photo', 'add', array($albumId, array('filedataid' => $response['filedataid'])));
I get this error:

Code:
Array
(
    [errors] => Array
        (
            [0] => Array
                (
                    [0] => invalid_data
                )
        )
)
--------------- Added [DATE]1492129526[/DATE] at [TIME]1492129526[/TIME] ---------------

Also, I noticed that in the vb_filedata table, that it had resized my test image (scaled it down). Is there some way to prevent that? These need to stay in their native 1920x1080 resolution. Thanks!
Reply With Quote
  #4  
Old 04-14-2017, 06:32 PM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by incursio View Post
Also, I noticed that in the vb_filedata table, that it had resized my test image (scaled it down). Is there some way to prevent that? These need to stay in their native 1920x1080 resolution. Thanks!
In the Attachment Type Manager, you can configure the maximum width and height and filesize for each file extension.
Reply With Quote
  #5  
Old 04-17-2017, 11:52 AM
incursio incursio is offline
 
Join Date: Nov 2001
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Any ideas on the actual call to "$api->callApi('content_photo' ...."? Is that the right call to use? If so, not sure what the arguments need to be.

I've also tried this, but to no avail:

Code:
   // Upload the file and add it
   $response = $api->callApi('content_attach', 'upload', array('file' => $fileInfo));

   $data = array(
     'parentId' => $albumId,
     'filedataid' => $response['filedataid'],
   );

   $response = $api->callApi('content_photo', 'add', array('data' => $data));
Reply With Quote
  #6  
Old 04-22-2017, 08:42 PM
incursio incursio is offline
 
Join Date: Nov 2001
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Anyone?
Reply With Quote
  #7  
Old 04-23-2017, 01:45 AM
noypiscripter's Avatar
noypiscripter noypiscripter is offline
 
Join Date: Jul 2013
Posts: 468
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Take a look at the actionGallery() function in /includes/vb5/frontend/controller/createcontent.php. That's the function called when you submit a gallery content type post.
Reply With Quote
  #8  
Old 04-23-2017, 02:32 PM
incursio incursio is offline
 
Join Date: Nov 2001
Posts: 46
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, mate! I'll take a peek.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:16 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.03848 seconds
  • Memory Usage 2,231KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (7)bbcode_code
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (8)post_thanks_box
  • (8)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (8)post_thanks_postbit_info
  • (8)postbit
  • (8)postbit_onlinestatus
  • (8)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete