mnylc / islandora_multi_importer

This is a flexible, twig based, all cmodel, tabular data to islandora Object importer with optional ZeroMQ processing
GNU General Public License v3.0
16 stars 15 forks source link

smb:// File Get Not Working #69

Closed McFateM closed 6 years ago

McFateM commented 6 years ago

I keep getting errors like the following in the latest code...

    HTTP error -1003 occurred when trying to fetch smb://132.161.10.13/LIBRARY/LIBSTU/AlumniOralHistories/Complete/ReadyForIMI/Douglas_Peterson_50/Doug_Peterson_50.MP3.
    HTTP error -1003 occurred when trying to fetch smb://132.161.10.13/LIBRARY/LIBSTU/AlumniOralHistories/Complete/ReadyForIMI/Douglas_Peterson_50/IOH-Peterson.xml.

I've tried many forms of these file specs but no matter what smb:// always returns errors like this even though 'smb' is in the list of valid request schemes. When debugging this I consistently see this code...

  $result = drupal_http_request($url);
  if ($result->code != 200) {
    drupal_set_message(t('HTTP error @errorcode occurred when trying to fetch @remote.', array('@errorcode' => $result->code, '@remote' => $url)), 'error');
    return FALSE;
  }

...in system.module returning a code of 1003.

DiegoPino commented 6 years ago

Smb!! Ok will debug. Is your mount case sensitive?

McFateM commented 6 years ago

I don’t think it is case sensitive. Thanks Diego.

DiegoPino commented 6 years ago

@McFateM did my homework and Drupal is to blame here (culprit!) I based my code to discern what is local/remote on this

Happens that samba/NFS/ftp are routed to system_retrieve_file where finally drupal_http_request gets called BUT: drupal_http_requestonly knows about http, https and feed. So all bad there. 1003 code means unknown schema.

Changes I need to make handle anything not HTTP or HTTPS as possibly stream wrapper (instead of remote via drupal_http_blabla). Then check if the given stream wrapper actually exists

print_r(stream_get_wrappers());

Array
(
    [0] => https
    [1] => ftps
    [2] => compress.zlib
    [3] => compress.bzip2
    [4] => php
    [5] => file
    [6] => glob
    [7] => data
    [8] => http
    [9] => ftp
    [10] => phar
    [11] => zip
    [12] => public
    [13] => temporary
)

Issue here is to enable smb:// or anything not standard we need to include a library and a unix client like this https://github.com/munkie/samba And that will make stuff way to complicated for other people to deploy. The solution: make a new hook that can allow people to deploy other different stream wrappers.

I will make some changes tonight but i will need you to help me figure out where to add the hooks (register wrappers?) so they are available when fetching is needed. I will provide a demo submodule using this one https://docs.aws.amazon.com/aws-sdk-php/v3/guide/service/s3-stream-wrapper.html so other people can follow.

McFateM commented 6 years ago

Thanks Diego. I did see the drupal_http_request() call in the code yesterday and wondered what kind of alternative would be necessary.

Personally, I'd just remove 'smb' from the list of acceptable schemes and we could rely on the hook I've provided to handle SMB requests. If you want to take that approach I'd be happy to try enhancing my hook implementation and provide an example to share. I've already made changes to that hook implementation to report the hook(s) that succeed or fail so that folks who implement the hook will have a better idea what it has done.

McFateM commented 6 years ago

Update: Since my hook is not working in the new code I'd suggest a solution like the one you proposed above. I can certainly help with calling the hooks if you can create a sample one that works. Thanks.

DiegoPino commented 6 years ago

Cool. Will keep this one open once i have the code working. Will need your testing of course.

McFateM commented 6 years ago

Good morning @DiegoPino. Have you made any progress with SMB? I could really use it and started to try and implement in my hook this morning with https://github.com/icewind1991/SMB but immediately ran into an issue: that project requires PHP 5.6 or greater, and my target server is still running PHP 5.5.9. 8^(

For now I may focus instead on adding a "hook" option to the pull-down that provides download mechanisms, that way we need not burden the "*local" option with something that is obviously not "local".

DiegoPino commented 6 years ago

Hi? Just curiousity, but for your smb share would it not be simpler to mount it first on the server as local mount? Most of my dev will sadly point to newer PHP versions and since you are moving to ISLE i would guess you will end using sooner or later php 7.x

El El jue, 3 de may. de 2018 a las 09:49, Mark McFate < notifications@github.com> escribió:

Good morning @DiegoPino https://github.com/DiegoPino. Have you made any progress with SMB? I could really use it and started to try and implement in my hook this morning with https://github.com/icewind1991/SMB but immediately ran into an issue: that project requires PHP 5.6 or greater, and my target server is still running PHP 5.5.9. 8^(

For now I may focus instead on adding a "hook" option to the pull-down that provides download mechanisms, that way we need not burden the "*local" option with something that is obviously not "local".

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/mnylc/islandora_multi_importer/issues/69#issuecomment-386301767, or mute the thread https://github.com/notifications/unsubscribe-auth/AGn859bkROKcZ8n1WdvVYzhUzO2ZXUbJks5tuwrOgaJpZM4TtQHF .

-- Diego Pino Navarro Digital Repositories Developer Metropolitan New York Library Council (METRO)

McFateM commented 6 years ago

Yep, I was just thinking along those lines too. The other night I found some guidance about mounting the share as CIFS and accessing it that way. I might just give that a spin this morning in my hook implementation. Thanks. I'll keep you posted.

petermacdonald commented 6 years ago

I mount a windows SAN as a CIFS share on our CentOS box for purposes of Islandora ingest. If you want the code I'll send it to you or I'll ask Steve to do so.

Peter

McFateM commented 6 years ago

No need, but thanks Peter. I've got my mount strategy worked out already. In fact, I am ingesting a few hundred new objects with it right now. My mount is from a Samba network share...

sudo mount -t cifs -o username=mcfatem //storage.grinnell.edu/LIBRARY/mcfatem/PHPP_Content /mnt/storage

DiegoPino commented 6 years ago

@McFateM #70 merged. I would say we can close this one for now? I will test public:// and private// tomorrow to see if they actually resolve or not. Thanks a lot

McFateM commented 6 years ago

Yes. Thanks for all your help and good work on IMI (and so much more).