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

auth’s picture

Issue summary: View changes
marcingy’s picture

Category: Bug report » Feature request
Status: Active » Needs review

Status: Needs review » Needs work

The last submitted patch, services-allow-mov-in-file-create_raw.patch, failed testing.

omegacoder’s picture

besides mov file, other video formats will be required for typical use cases e.g. mp4

bohemel’s picture

Added support for mp4 in the patch.

rasikap’s picture

rasikap’s picture

Status: Needs work » Needs review
auth’s picture

Status: Needs review » Needs work

Using 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.

rasikap’s picture

I 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.

auth’s picture

There 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.

sitiveni’s picture

Hi, 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.

sitiveni’s picture

StatusFileSize
new2.11 KB

Oops, patch before (#11) was quite a bit off. Here goes again.

kylebrowning’s picture

Status: Needs work » Needs review
+++ b/resources/file_resource.inc
@@ -421,8 +426,8 @@
+  $extensions = variable_get('services_allowed_extensions', $default = NULL);
+++ b/resources/file_resource.inc
@@ -205,7 +205,12 @@
+    if ($extensions = variable_get('services_allowed_extensions', NULL)) {

Why 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.

kylebrowning’s picture

Status: Needs review » Needs work
sitiveni’s picture

Right you are. There you go.

kylebrowning’s picture

Status: Needs work » Needs review
Chipie’s picture

Status: Needs review » Reviewed & tested by the community

Works great here.

tyler.frankenstein’s picture

Status: Reviewed & tested by the community » Fixed

Looks good, thank you everyone.

amar.deokar’s picture

Is there any example of create_raw api ?

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

tyler.frankenstein’s picture

Here's a Drupal Services File Create Raw example courtesy of @Chipie that works with PhoneGap/Cordova: https://gist.github.com/signalpoint/8a0dc14c9553552a046a97abe9f2e48c

digitalfrontiersmedia’s picture

Status: Closed (fixed) » Reviewed & tested by the community

I'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".

tyler.frankenstein’s picture

Hmmm, 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

digitalfrontiersmedia’s picture

Thanks 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.

kylebrowning’s picture

Yeah, I made a mistake with the tag. 3.17 coming out shortly.

kylebrowning’s picture

Status: Reviewed & tested by the community » Fixed
digitalfrontiersmedia’s picture

Thank you!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

mozh92’s picture

Hello 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

mozh92’s picture