In the latest release movies with extension .mov uploaded using create_raw are renamed .mov_.txt.
These file extensions "jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp" are what I can see the only ones allowed. In my case I also need mov to be allowed so because I did not find any other way to do it I added it in this module with the attached patch.
I believe the allowed extensions should be configurable in some way but I do not know the mos services friendly approach to achieve it. Any advice on the matter would be appreciated.
Comments
Comment #1
auth commentedComment #2
marcingy commentedComment #4
omegacoder commentedbesides mov file, other video formats will be required for typical use cases e.g. mp4
Comment #5
bohemel commentedAdded support for mp4 in the patch.
Comment #6
rasikap commentedComment #7
rasikap commentedComment #8
auth commentedUsing a variable to store the allowed file extensions is an excellent approach. The patch in #6 will however unfortunately break existing sites since no update hook is provided to set the variable if the module is already enabled. This is easily fixed by adding one but I believe a simpler approach would be to add the existing file extensions list as the default variable value. This also removes the need for an enable hook.
Replacingthe line
$extensions = 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp';
with
$extensions = variable_get('services_allowed_extensions', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');
should do the trick.
I can provide a patch later if appreciated.
Comment #9
rasikap commentedI think just adding variable_get and placing the default values instead of NULL, will either not solve the problem, as the variable would never be set for existing sites. So we can first check if variable_get gives us the extension, else we set it in our code itself, so that the users having existing sites can still edit the extensions list. Also we can keep the hook enable for new installations. Please suggest.
Comment #10
auth commentedThere is no need to set the variable for existing sites since they are fine with the default value.
The beauty of the second argument to variable_get is that is is used if the variable is not set. If a site needs more file extensions than currently hard coded the option to set the variable to another value will be enough to solve the problem.
Comment #11
sitiveni commentedHi, thanks for the work/patches that's already been done here.
Setting the allowed extension as file validator when calling file_save_upload().
This actually has been done in the patch #5 (manually entered file extension instead using a variable), but did not make it into patch #6.
This patch is basically a combination of #5 + #6; hence all the credits goes to bohemel and rasikap.
Comment #12
sitiveni commentedOops, patch before (#11) was quite a bit off. Here goes again.
Comment #13
kylebrowning commentedWhy not just
$extensions = variable_get('services_allowed_extensions', 'jpg jpeg gif png txt doc xls pdf ppt pps odt ods odp');And
if ($extensions = variable_get('services_allowed_extensions', 'jpg jpeg gif png txt doc xls pdf ppt pps odt dos odp'))Otherwise we need an update hook to set the variable as well.
Comment #14
kylebrowning commentedComment #15
sitiveni commentedRight you are. There you go.
Comment #16
kylebrowning commentedComment #17
Chipie commentedWorks great here.
Comment #19
tyler.frankenstein commentedLooks good, thank you everyone.
Comment #20
amar.deokar commentedIs there any example of create_raw api ?
Comment #22
tyler.frankenstein commentedHere's a Drupal Services File Create Raw example courtesy of @Chipie that works with PhoneGap/Cordova: https://gist.github.com/signalpoint/8a0dc14c9553552a046a97abe9f2e48c
Comment #23
digitalfrontiersmediaI'm confused. Comment #18 seems to indicate that this change was committed on July 6, 2016 13:32 (https://www.drupal.org/commitlog/commit/2634/eaf572c47e38b13fa37e25c9b2a61bf54209ab07). The issue was marked as "fixed" and a new release 7.x-3.16 came out on August 1, 2016 (about 3 weeks after the commit). I just upgraded and the changes found in comment #15 (https://www.drupal.org/files/issues/services-allowed_extensions_in_file_create_raw-2502281-15-d7.patch) are not present in the release. Am I misunderstanding something here?
I'm re-opening this since the fix hasn't actually been released. I'm changing the status back to RTBC to make sure that this issue isn't neglected and mistaken as "fixed" in case something has gotten borked during the release procedure. I'd appreciate an update to understand why this hasn't been released as expected. Then once we understand why, we can mark this back as "fixed".
Comment #24
tyler.frankenstein commentedHmmm, this also happened here: https://www.drupal.org/node/2472757#comment-11517375
@kylebrowning, any idea what why a few commits didn't make it into the latest release? https://www.drupal.org/project/services/releases/7.x-3.16
Comment #25
digitalfrontiersmediaThanks for looking into this, @tyler.frankenstein. I was also just wondering if it was something I was misunderstanding. But since you've found another instance, I guess it's not just me! :-) Hopefully it's not something systemic that will cause headaches for maintainers.
Comment #26
kylebrowning commentedYeah, I made a mistake with the tag. 3.17 coming out shortly.
Comment #27
kylebrowning commentedComment #28
digitalfrontiersmediaThank you!
Comment #30
mozh92 commentedHello All, I had some problems with extensions.
I need to use '.zip' and '.7z', but I have '_.txt' and '.txt'.
Maybe we can use a page with a form in admin to manually update the list with extensions
Comment #31
mozh92 commented